开发者

Is it possible to use the NPAPI interface to download files without using the local cache?

开发者 https://www.devze.com 2022-12-31 11:40 出处:网络
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 plu

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 l开发者_如何学运维ocal 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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消