• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 227
  • Last Modified:

JSP Caching

I have a set of JSP which I do nto want to cach. I tried using the folowing:

      <meta http-equiv="Pragma" content="no-cache">
      <meta http-equiv="Cache-Control" content="no-store">

but it does not seem to work even though I have re-started tomcat after deleting its work direcotry. Is there anyone who can give me a clue why this is happening or why the above did not make any effect.

2 Solutions
use this (from TimYates)

        // Set to expire far in the past.
        response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
        // Set standard HTTP/1.1 no-cache headers.
        response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
        response.addHeader("Cache-Control", "post-check=0, pre-check=0");
        // Set standard HTTP/1.0 no-cache header.
        response.setHeader("Pragma", "no-cache");
Sometime, browser or proxy doesn't respect the HTTP header.
One workaround could be append a dummy parameter in your URL, such as "rnd=213657192312"
Try to go to the web directory in tomcat. Try to edit the file or the page by putting a space in the first and save it. And reload the page.


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now