Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the effect of hostname aliases on Java applet cache?

Tags:

java

applet

I have two servers with hostnames comp1 and comp2. I also have a floating alias (master) that is dynamically mapped to one of the two servers. I am serving the same identical applet from both servers. Clients normally connect to the master one, but it is perfectly allowable to connect to either comp1 or comp2 directly.

Clients are complaining that they are always having to wait for the applet to load (it is quite large). I thought that once the client downloaded the necessary jars, they would be cached and wouldn't be loaded again. At first I thought the client's plugin was set to not cache, but I think I've found the cause of the problem, although I don't understand it.

  1. Connect client to master (which is currently pointing to comp1) for the first time. Must wait for jars to download. This is expected.
  2. Connect client to master again. I don't have to wait for the jars to download. This is also expected/desired behavior.
  3. Connect client to comp1. Must wait for jars to download. I'd rather not have this happen, since it is the same server, but I can understand why, as comp1 appears to the client as a completely different host.
  4. Connect client back to master. Again, I must wait for all the jars to download. This is not what I expected. The jars should have been downloaded already in steps 1/2.

Using the Java control panel, I can see the resources that are in the cache. It appears to me that the resources are keyed by URL, so I don't know why I'm getting what I do. It seems as though that the two different hostnames for the same server is messing up the client's cache.

I should mention that the master hostname isn't just a DNS alias. It is an actual different IP addrress that comp1/comp2 dynamically bind/unbind to while the application is running.

Can you explain what I am seeing here, or suggest some avenues to investigate?

like image 885
wolfcastle Avatar asked Apr 27 '11 19:04

wolfcastle


1 Answers

Avenus to investigate:

This may well be a consequence of the jar filename - e.g. if it is always downloaded into %TMP%\app.jar, then app.jar will get stomped on each time you visit a server.

Possible workarounds:

  • Alias the file on the servers, so it can be fetched as master.jar, compN.jar
  • Use a 301 or 302 to hint to the browser than only one source jar is used (you may need to sign the jar due to same-origin policies)
like image 166
Phil Lello Avatar answered Oct 21 '22 03:10

Phil Lello