• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to avoid caching

 
saran sadaiyappan
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I want the caching facility of the browser to be disabled.i.e even after clicking the back button in the browser he should not be taken back but the message "page expired" to be displayed.Can anyone help me?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can't be controlled from the server side... it has to be done in the browser.

Moving to the general computing forum.
 
Rigel Kentaurus
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by saran sadaiyappan:
Hi all,
I want the caching facility of the browser to be disabled.i.e even after clicking the back button in the browser he should not be taken back but the message "page expired" to be displayed.Can anyone help me?


Use this code in every servlet:

response.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
response.setHeader("Pragma", "no-cache");

No waranty, but the browser is sent the instruction of not storing in the cache that page
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic