aspose file tools*
The moose likes Servlets and the fly likes Question on cache control... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Question on cache control..." Watch "Question on cache control..." New topic
Author

Question on cache control...

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Hi friends,
I am trying to prevent caching of pages. i.e. any time a page is revisited,I want my servlet to be invoked for latest results, so is it right if I just add this line to stop caching and servlet bring the latest version?
response.setHeader("Cache-Control","no-cache");
Many thanks for your help,
Elahe


Thanks,
Elahe
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

There is some browser-specific behaviour here, so it is slightly more complicated.
This is the solution I tend to use:

Dave
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Hi david,
Thanks you so much for your answer and I tested it
response.setHeader("Cache-Control","no-
res.setHeader("Cache-Control","no-cache");//HTTP 1.1
res.setHeader("Pragma","no-cache"); //HTTP 1.0
res.setDateHeader ("Expires", 0); //prevents caching at the proxy server
and even I have this in my HTML code:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma-directive" CONTENT="no-cache">
<META HTTP-EQUIV="cache-directive" CONTENT="no-cache">
<META http-equiv="Expires" content="Tue, 01 Jan 1980 1:00:00 GMT">
but it still taking the data from cache. Do you have any clue, what might be wrong here. I will appreciate your help.
Thank you Dave
Elahe
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
And if you like to take a look on my servlet
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Sorry here please:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on cache control...