Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preventing Old page to get loaded

 
Shailesh Gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look into the no-cache and expires pragma headers.
 
Shailesh Gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try


also, most of your setHeader commands should be addHeader commands instead.
[ June 07, 2006: Message edited by: Martin Simons ]
 
Shailesh Gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic