What approaches are available for caching within a Java applet?
I gather that the .jar that makes up the applet will be cached by most browsers.
- Will this be the case for any dependent .jars used by the applet?
- If the applet loads resources from a remote URL at runtime, is it correct to assume that this will not be cached by the browser? If it is not cached by the browser, would one be able to implement caching by writing to local storage?
According to How to disable http caching in applet and URLConnection JavaDoc caching will be enabled when requesting a resource programatically.
Yes, assuming that the dependent JARs are cacheable.
Probably yes. The JVM will probably connect directly to the remote server, and the browser won't see the HTTP request. In addition, the JVM will probably be unaware of the browser's cache organization or location. However, this is all platform dependent.
It is also possible that the JVM could implement its own HTTP cache. AFAIK, current generation Oracle JVMs don't, but it is not inconceivable that future ones might.
Only if the applet is signed, and the user has accepted the signature. An applet normally can't read or write local storage.
For better control of resource caching, deploy the applet using Java Web Start which offers:
Note that a JWS app. does not need to be trusted to invoke the programmatic updates part of the JNLP API.