How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
Just execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached at the browser. You need both the statements to take care of some of the older browser versions.
<% response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 response.setHeader("Pragma","no-cache"); //HTTP 1.0 response.setDateHeader ("Expires", 0); //prevents caching at the proxy server %>
response.setHeader("Cache-Control","no-store"); //HTTP 1.1The difference between no-cache and no-store is a bit dodgy, but apparently no-cache is the more polite keyword. -Alex]
However, please note that there are some problems with disabling page caching under IE 5.0 due to the unique buffering requirements of the browser. Please see the Microsoft knowledge base for details: