2

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

Community
  • 1
  • 1
Umer Hayat
  • 1,993
  • 5
  • 31
  • 58

2 Answers2

7

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.

michael667
  • 3,241
  • 24
  • 32
  • It's not possible to provide and then call the applet from unique uri, as stated earlier, in a comment in 'other' question. Applet tries to reloads itself after a specific time period, how is it possible for it to call unique uri everytime? I might be missing something. – Umer Hayat Oct 10 '11 at 12:09
  • 2
    You just have to add some random parameters at the end of the URL which are not used by the server, e.g. `?my_parameter=12345`, where the value of the parameter changes each time. This prevents caching, as the browser cannot know that the parameter is actually unused and in fact the same resource will be loaded again. – michael667 Oct 10 '11 at 12:17
  • Ok!, now i got it. First I was thinking that I would have to change applet name and then sync my URl accordingly. But this random parameter solution worked, Thanks :) – Umer Hayat Oct 11 '11 at 06:12
1

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.

Community
  • 1
  • 1
HashimR
  • 3,803
  • 8
  • 32
  • 49