wood burning stoves 2.0*
The moose likes JSP and the fly likes prevent page caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "prevent page caching" Watch "prevent page caching" New topic
Author

prevent page caching

James Hoare
Greenhorn

Joined: Aug 11, 2006
Posts: 9
I have a problem with one of my pages caching and I need a way of preventing this. I have tried adding the following to the page, but it doesn't prevent caching in IE or FF?

<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);
%>

The problem I have is that when a user clicks on the back button in the browser the form details are still present, I would like to prevent this.

Please can you help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
The web app has no control over what the browser does upon clicking the back button. Most of the times, the browser will re-display its cached version of the previous page, no matter what the cache settings are. That's just how the Back button works.

What problem does that present to your application? There may be ways to prevent any possible negative side effects.


Ping & DNS - updated with new look and Ping home screen widget
James Hoare
Greenhorn

Joined: Aug 11, 2006
Posts: 9
Thanks for the quick response. The problem is that the details cached are credit card details, therefore ideally I would like the information removed from the form if the back button is used.
Lauri Lehtinen
Greenhorn

Joined: Oct 11, 2007
Posts: 1
Hi,

I struggled with a pretty much identical case a while ago - I found no way of preventing the browser of caching a page and letting the user access it by clicking on the Back button, even after they had logged out. I was looking at the headers set by my Internet bank site and some webmails, until I realised it was the use of https that did the trick. I wasn't using https on my development machine, which caused the confusion. Since you're handling credit card info, I'd assume you'll be using https in production as well?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prevent page caching
 
Similar Threads
problem in caching jsp pages
Caching Problem with JNLP
roblem when caching with Internet Explorer 6.0
submit button only works once?
Problem with cache and session