how to tell browser not to cache documents

I had to find a way to make sure the browser doesn’t cache PDF documents on the local file system. IE for instance downloads a copy towards C:/Documents and Settings/userDirectory/Local Settings/Temporary Internet Files/ (which is the default, can be changed through Tools > Internet Options > Tab General and click Settings on panel Temprary Internet Files).

The solution was actually very easy, add the following HTTP headers to your response, that’s it.


response.setHeader("Cache-Control","no-cache"); // for HTTP 1.1
response.setHeader("Pragma","no-cache"); //for HTTP 1.0
response.setDateHeader ("Expires", 0); //for proxy server
response.setHeader("Cache-Control","no-store"); //HTTP 1.1

source:
http://java.ittoolbox.com/groups/technical-functional/java-l/how-to-avoid-caching-of-pages-in-temporary-internet-files-folder-721490

Leave a Reply

Your email address will not be published. Required fields are marked *

Please reload

Please Wait