Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 514269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:30:26+00:00 2026-05-13T07:30:26+00:00

I created a Servlet filter with the following code in doFilter: HttpServletResponse httpResponse =

  • 0

I created a Servlet filter with the following code in doFilter:

HttpServletResponse httpResponse = (HttpServletResponse)response;

httpResponse.setHeader("Cache-Control","no-cache");
httpResponse.setHeader("Pragma","no-cache");
httpResponse.setDateHeader("Expires", 0); 

chain.doFilter(request, response);

I want to make sure that nothing gets cached at the Client and every request (even the one’s from the Browser’s back button) are directed to the Server.

But, even after implementing the above filter, some pages are cached (accessible using browser’s back button).

And other pages that are not cached, show Web Page Expired error in Internet Explorer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:30:26+00:00Added an answer on May 13, 2026 at 7:30 am

    To start, the complete set is:

    httpResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
    httpResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0.
    httpResponse.setDateHeader("Expires", 0); // Proxies.
    

    The no-store and must-revalidate are required to get it to work in under each Firefox.

    But, even after implementing the above filter, some pages are cached (accessible using browser’s back button).

    How did you test it? Those headers will actually prevent the browser from requesting the page from the browser cache instead of directly from the server. Best test is to have a Filter to listen on /* and add a debug statement in flavor of:

    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String method = httpRequest.getMethod();
    String URI = httpRequest.getRequestURI();
    System.out.println(method + " request invoked on " + URI);
    

    This should print the actual requests.

    Also ensure that you don’t override the headers in the JSP page itself using the HTML <meta> tags.

    And other pages that are not cached, show Web Page Expired error in Internet Explorer.

    You can only get this if the non-cached request was POST request, not a GET request. The GET requests will simply be requested from server again instead of from the browser cache.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: I created the servlet which should draw a dynamic
I created java ee application with this tutorial: http://prideafrica.blogspot.com/2007/04/simple-authentication-servlet-filter.html but I do not know
I want to add logging to my Servlet, so I've created Filter which should
The following servlet filter is getting called, but not able to give the correct
I've created a servlet for sending the exception or error details to the webmaster.
I have created a servlet that passes a string variable strname to a JSP
I created one GWT webapplication project.Inthat i want to create servlet program,but in that
If I create following the Servlet 3.0 specification a web application fragment how can
I have created a servlet mapping as /reskilling in my Servlet class. When I
I created simple Java Servlet: WelcomeServlet.java. Than, I tried compile this file via: javac

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.