DeejUK
DeejUK

Reputation: 13481

Caching in Java Applets

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.

Upvotes: 2

Views: 1459

Answers (3)

DeejUK
DeejUK

Reputation: 13481

According to How to disable http caching in applet and URLConnection JavaDoc caching will be enabled when requesting a resource programatically.

Upvotes: 0

Andrew Thompson
Andrew Thompson

Reputation: 168825

For better control of resource caching, deploy the applet using Java Web Start which offers:

..automatic update (including lazy downloads and programmatic control of updates)..

Note that a JWS app. does not need to be trusted to invoke the programmatic updates part of the JNLP API.

Upvotes: 2

Stephen C
Stephen C

Reputation: 718926

Will this be the case for any dependent .jars used by the applet?

Yes, assuming that the dependent JARs are cacheable.

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?

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.

If it is not cached by the browser, would one be able to implement caching by writing to local storage?

Only if the applet is signed, and the user has accepted the signature. An applet normally can't read or write local storage.

Upvotes: 3

Related Questions