Search code examples
javahtmlcachingappletnext-generation-plugin

How do I update the cache for an applet?


I am trying to update the cache for an applet. The applet properly caches, but afterwards, no matter how stale the cache is, it won't update. If I manually delete the cache, a new one will be created upon the next page load, and all changes to the .jar file I am trying to cache take effect. Having to do this, though, is not acceptable.

I have tried using cache_archive in conjunction with cache_version in my index file like so:

if (navigator.appVersion.indexOf("Win")!=-1){
    var attributes = { id:'manager', code:'HardwareManagerApplet_FileWriter',          width:1, height:1} ;
    var parameters = {jnlp_href: '/java/HardwareManagerApplet.jnlp', codebase: '/java/hardwaremanager.jar', cache_archive:'hardwaremanager.jar',  cache_version:'0.0.0.7'};
    check = deployJava.runApplet(attributes, parameters, '1.6');
    hardware_enabled = true
    console.log("Applet started")
}

This is having no effect. I have tried moving cache_archive and cache_version to attributes and as various permutations between to no avail. I have tried enabling cache_option set to first browser, then tried again setting it to plugin. No dice. I've looked into ETags, and I'm not confident that will be the best solution. I've also looked into last-Modified, but A) I'm not sure how to implement it into the http so the cache will update and B) that will open a whole new can if I have to go that route.

Is there any other reasonable alternative? Better yet, am I simply implementing cache_archive et al incorrectly?

And actually, even if I can get it to cache every single time the page loads, I will be satisfied.

Thanks for all and any help!

Edit: The block of code about is the ONLY implementation I've made of cache_archive etc. Do I need to put in a couple lines elsewhere? As far as Oracle's documentation went, I didn't find that to be very clear.


Solution

  • Your missing the parameter for the cache option they are as follows

    The cache_option attribute can take one of three values:

    • No - Disable applet installation. Always download the file from the web server.
    • Browser - Run applets from the browser cache (default).
    • Plugin - Run applets from the new Java Plug-in cache.

    By defaulting to browser you would have to clear the browser cache for the updated values to take effect. Use plugin to take full advantage of the versioning you want to implement.