jeudi 22 octobre 2015

Browsers don't cache downloaded file when using HTTP Cache-Control header

I have a web application that offers file downloading functionality. I would like to enable browser cache (Cache-Control header) so that subsequent downloads of a file come from the browser cache, instead of generating a new HTTP Request to the server.

HTTP Request:

http://localhost:9080/webapp/action/content/somefile.exe

HTTP Response:

Cache-Control:max-age=600
Content-Disposition:inline;filename="somefile.exe"
Content-Length:20952624
Content-Type:application/x-msdownload
Date:Thu, 22 Oct 2015 10:46:17 GMT
Last-Modified:Thu, 22 Oct 2015 10:44:49 GMT
X-Powered-By:Servlet/3.1

However, despite the Cache-Control header, the browser (latest releases from Firefox & Chrome) always asks the server for the file. Any idea why?




Aucun commentaire:

Enregistrer un commentaire