Umer Hayat
Umer Hayat

Reputation: 2001

how to remove old applet from browser's cache programmatically?

Is there a way to delete older version of an applet from browser's cache? The things I have already tried to prevent the cache problem in first place are:

1- To set "no-cache" in HTTP response header, I placed following script on the top of my jsp:

<% 
if (request.getProtocol().compareTo("HTTP/1.0") == 0) {
            response.setHeader("Pragma", "no-cache");
        } else if (request.getProtocol().compareTo("HTTP/1.1") == 0) {
            response.setHeader("Cache-Control", "no-cache");
        }
        response.setDateHeader("Expires", 0);
%>

2- While deploying applet 'cache_option' is set to 'no'

But of no use. I was now wondering if there is a way to programatically delete this applet jar file from cache?

[UPDATE]

Providing a unique url for applet each time doesn't look like a good idea in my case. As, in my case applet reloads(refresh) itself after a time (say at mid-night, using Timer), hitting on a url

applet.getAppletContext().showDocument(url); 

It would be difficult to communicate new url to applet

Upvotes: 2

Views: 9410

Answers (2)

HashimR
HashimR

Reputation: 3833

these links might be of your help:

Applet Caching and Installation in Java Plug-in

how-to-clear-cache-to-reload-applet

How to disable http caching in applet

How to disable browser applet cache..?

Java applet cached forever, not downloading new version?

There are a couple of solutions to your problem. The one which is discussed more in the links, is to use a different name for every applet jar file. Append version number or anything so as to ensure that browser loads the applet from the server every time it runs, rather then from the cache. You can get more help from the above pasted links. Thanks.

P.S. The links are pasted in order of relevance.

Upvotes: 1

michael667
michael667

Reputation: 3260

The answer you got on your other question also applies here: Provide a unique url for your applet each time. It's not humor, as lots of people are using this technique and it would solve your problem.

Upvotes: 7

Related Questions