File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on cache control...

 
Elahe Shafie
Ranch Hand
Posts: 291
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 291
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 291
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you like to take a look on my servlet
 
Elahe Shafie
Ranch Hand
Posts: 291
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry here please:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic