aspose file tools
The moose likes Servlets and the fly likes Clearing cache in servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Clearing cache in servlets" Watch "Clearing cache in servlets" New topic
Author

Clearing cache in servlets

ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

I am trying to clear cache using servlets, to prevent duplicate records getting inserted. My servlets has some header variable information relating to username.
I am trying to clear the cache by using:
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 1);
But, this doesnt seem to work. Can anybody please help.

Thanks
[ February 08, 2006: Message edited by: ford Darcy Jr ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56202
    
  13

That will not clear the cache. It will tell the browser not to cache the current "page".


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

Thanks for the reply. Can you please tell me, what should I modify in that to get a solution.

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56202
    
  13

There is no way for a response to tell the browser to clear its cache. That is completely under user control.
ford Darcy Jr
Ranch Hand

Joined: Jan 26, 2005
Posts: 76
Hi,

Clearing cache using the response.setHeader("cache", "no-cache"), works fine on tomcat, but doesnt work when moved to weblogic server. Any idea what needs to be used on weblogic server for clearing cache to work.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56202
    
  13

You are mistaking clearing the cache with preventing a page from being cached in the first place.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Clearing cache in servlets
 
Similar Threads
Servlet and IE Back Button...help!!
Making a page expire
Struts 2 - logout - prevent back button
javascript