JSP Caching

Posted on 2005-04-18
Last Modified: 2010-03-31
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.

Question by:kohonen
    LVL 29

    Accepted Solution

    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");
    LVL 2

    Assisted Solution

    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"
    LVL 3

    Expert Comment

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now