tags:

views:

62

answers:

1

I am writing a browser plugin using NPAPI and as part of the plugin I need to download a file. For this I have been using the NPN_GetURL function out of the NPNetscapeFuncs structure provided to my plugin after it is loaded.

This works fine except that if the file has already been downloaded, Firefox seems to always pull the file out of the local cache rather than off of the provided URL. And this happens regardless of what request mode I give it in the NPP_NewStream function that I've defined.

Is it possible to bypass the cache or am I left using other methods to download the file? Ideally it would only download if a newer version exists on the server (and otherwise take it out of the cache) but right now I would settle for always downloading.

+3  A: 

NPN_GetURL() acts in the same way as the browser when is gets an URL for displaying it. Therefore I would expect it to fetch the file from the server if it is newer than what is available in the cache.

Have you checked (e.g. using the Fiddler tool when you're on Windows) if the browser is actually contacting the server when the file is already in the local cache and maybe getting a 304 status code (Not Modified) in the response?

If you want more control over the GET request like setting or altering the http headers then you have to use one of the platform dependent libraries (WinInet/WinHttp on Windows or libcurl on Linux/OSX).

Volker Voecking
Thanks. Turns out I didn't fully understand how caching was supposed to work. Problem was resolved by changing the server to respond with header Cache-Control = must-revalidate, no-cache
averisk