aspose file tools*
The moose likes Servlets and the fly likes Caching is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Caching is not working" Watch "Caching is not working" New topic
Author

Caching is not working

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
I had designed a web application with username/password logging in a JSP page and verification process in a servlet. I use sendRedirect to redirect to another JSP page with the message Welcome User. The problem I am facing is I am unable to stop the browser from caching web pages.

After logging in when I use BACK browser button I see the same form just submitted with the same values filled in. This is not my current state. Since user has already logged in when I use the back browser button both username/password text fields should be empty. This is what I am expecting. I used all cache controlling techniques

I included this in my Login JSP page

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">

and in servlets

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

But nothing is working. I appreciate if anyone can suggest how to solve this issue.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
The pages are not cached if I use response.setHeader("") in my login page. But I don't understand why all these meta tags not working.

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">

Why the jsp page requires setHeader("") methods.
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

if your network has a proxy server or firewall, the webpage is being cached on the proxy server. The browser cache-control would have no effect in the intermediate proxy server.


This is the answer. I am working in a Firewall network.

But how does a firewall cache web pages?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caching is not working