aspose file tools*
The moose likes General Computing and the fly likes how to avoid 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 » Engineering » General Computing
Bookmark "how to avoid caching" Watch "how to avoid caching" New topic
Author

how to avoid caching

saran sadaiyappan
Ranch Hand

Joined: Dec 23, 2004
Posts: 39
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

Joined: Oct 18, 2000
Posts: 4121

This can't be controlled from the server side... it has to be done in the browser.

Moving to the general computing forum.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Rigel Kentaurus
Greenhorn

Joined: Feb 09, 2005
Posts: 11
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to avoid caching
 
Similar Threads
JSP in Internet explorer
Pasted url vs link - extremely odd behavior
page not get refreshed
Changing Avatar pictures
refreshing using meta tag