Caching in Java Applets

2019-07-19 03:41发布

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?

3条回答
劳资没心,怎么记你
2楼-- · 2019-07-19 03:44

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

查看更多
干净又极端
3楼-- · 2019-07-19 04:05

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.

查看更多
干净又极端
4楼-- · 2019-07-19 04:07

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.

查看更多
登录 后发表回答