3

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.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Alex
  • 87
  • 1
  • 7

2 Answers2

2

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.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Keibosh
  • 1,237
  • 1
  • 9
  • 18
  • I wondered about that... I tried placing cache_option:plugin before cache_archive in the parameters var, but I was kind of just shooting in the dark. If I were to place cache_option:plugin back into that line, should it, in theory, work? It didn't last time, but I might be doing _that_ wrong or something else wrong too. – Alex Jul 12 '11 at 18:31
  • It definitely didn't solve everything, although it probably would have been a problem down the road. Thank you. – Alex Jul 12 '11 at 18:39
  • Its still not being cached properly? – Keibosh Jul 13 '11 at 14:04
  • Have you tried using the older object html tag to load the applet? It may also make things a little easier to debug. – Keibosh Jul 13 '11 at 14:14
0

The caching of an applet is the work of both the virtual machine (JVM) and your browser. The browser as well as the JVM are optimized for caching applet for performance purpose.

My solution were one of both:

  1. Clear the cache of the virtual machine after every classes build: open the Java console and type x (ClassLoader-Cache clear). Then refresh your browser. or
  2. Close your browser and start it all afresh

I prefer solution 1.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
arthur
  • 3,245
  • 4
  • 25
  • 34