aspose file tools*
The moose likes JSP and the fly likes Preventing Old page to get loaded Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Preventing Old page to get loaded" Watch "Preventing Old page to get loaded" New topic
Author

Preventing Old page to get loaded

Shailesh Gupta
Greenhorn

Joined: May 05, 2006
Posts: 7
Hi All,

Can any one tell me how can we prevent the old page from getting displayed to the user when he clicks the "Back" button of the browser. The old page is getting displayed when the back button is clicked, but I want the page to be loaded from server and not from cache.
Help in this matter will be greatly appreciated.

Thanks & Regards,
Shailesh


Never Say Never
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
look into the no-cache and expires pragma headers.
Shailesh Gupta
Greenhorn

Joined: May 05, 2006
Posts: 7
Originally posted by Martin Simons:
look into the no-cache and expires pragma headers.


well i have already done that by puting the code specified below in my JSPs. Its working fine when the Page is accessed using any links, but when the "Back" of the browser is clicked, the browser loads an older version of the page.


response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
response.setHeader("Cache-Control", "private"); // HTTP 1.1
response.setHeader("Cache-Control", "no-store"); // HTTP 1.1
response.setHeader("Cache-Control", "max-stale=0"); // HTTP 1.1

The problem is still there so if any 1 can tell me what can 1 do to resolve this, it wud be lot of help.
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
try


also, most of your setHeader commands should be addHeader commands instead.
[ June 07, 2006: Message edited by: Martin Simons ]
Shailesh Gupta
Greenhorn

Joined: May 05, 2006
Posts: 7
Hi Martin,

Thanks for the suggestion. but its not working. could u pls be a bit more specific of which setHeader statements should be addHeader statements. because now that i am testing the application at client, the problem of caching is still being faced.

Any one else who can solve the problem will be a gr8 help.

Regards,
Shailesh
 
wood burning stoves
 
subject: Preventing Old page to get loaded