Sun Java Solaris Communities My SDN Account Join SDN
 
Java Plug-in 1.3 Documentation

Applet Caching and Installation in Java Plug-in

 

Applet caching ensures that applets are not unnecessarily downloaded by a browser every time a user references them. 

Java Plug-in has supported disk caching in previous versions by using the same cache the browser uses for all other web documents. This works for casual applet usage, but larger applets can often get flushed from the cache to make room for other documents since the browser has no knowledge that an applet file might be needed in the future. The result is that this caching strategy fails where is needed most in large business applets.

This release introduces an alternative form of applet caching which allows an applet deployer to decide whether applet should be "sticky", that is, to stay on the disk in a secondary cache which the browser cannot overwrite. The only time "sticky" applets get downloaded after that is when they are updated on their server. Otherwise the applet is always available for quick loading. We recommend that applets which provide core business applications be made sticky to improve their startup performance.

This new feature is activated by including the new "cache_option" , "cache_archive" and "cache_version" values in the EMBED/OBJECT tag that specifies the use of Java Plug-in as below:

<OBJECT ....>
	 <PARAM NAME="archive" VALUE="...">
	 ....
	 <PARAM NAME="cache_option" VALUE="...">
	 <PARAM NAME="cache_archive" VALUE="...">
	 <PARAM NAME="cache_version" VALUE="...">
</OBJECT>

or
<EMBED ....
	 archive="..."
	 ....
	 cache_option="..."
	 cache_archive="..."
	 cache_version="...">

cache_option

The cache_option attribute can take one of three values:

No
Disable applet installation. Always download the file from the web server without using browser or plug-in cache.

Browser
Run applets from the browser cache (default).

Plugin
Run applets from the new Java Plug-in cache.

cache_archive

The cache_archive attribute contains a list of the files to be cached:

<PARAM NAME="cache_archive" VALUE="a.jar,b.jar,c.jar">

Like the archive attribute in the APPLET tag, the list of jar files in the cache_archive attribute do not contain the full URL, but are always downloaded from the codebase specified in the EMBED/OBJECT tag.

Note that the list of JAR files in the cache_archive attribute and those in the archive attribute may be similar but should not contain the same JAR files. There are two possible cases:

  1. A JAR file is listed in cache_archive but not in archive. In this case, the JAR file is cached according to cache_option.
  2. A JAR file is listed in archive but not in cache_archive. In this case, the JAR file is cached using the native browser cache. This guarantees a minimum of caching.
cache_option and cache_archive can only be specified once per EMBED/OBJECT tag. In addition, both attributes must be specified. If either cache_archive or cache_option are missing, Java Plug-in will treat the applet normally using the archive attribute.


cache_version

The cache_version is an optional attribute contains a list of versions of the files to be cached:

<PARAM NAME="cache_version" VALUE="1.2.0.1, 2.1.1.2, 1.1.2.7">

Each version number is in the form of X.X.X.X which X could be from 0 to F in hexadecimal. Each version number corresponds to the jar file in the cache_archive.

Applet Caching Update Algorithm

By default, without the cache_version attribute, applet caching will be updated if:

  • The cache_archive has not been cached before, or
  • The "Last-Modified" value of the cache_archive on the web server is newer than the one stored locally in the applet cache, or
  • The "Content-Length" of the cache_archive on the web server is different than the one stored locally in the applet cache. 

However, in some situations, the "Last-Modified" value returned from the web server through HTTP/HTTPS may not reflect the actual version of the applets. For example, if the web server crashes and all the files are restored, the cache_archive will have a different modification date on the server. Even if the cache_archive has not been updated, it will still force all the Java Plug-in clients to download the cache_archive again.

To strongly enforce the version update, we recommend the applet deployer use the cache_version attribute. Applet caching will be updated if:

  • The cache_version corresponding to the cache_archive in the EMBED/OBJECT tag is larger than the one stored locally in the applet cache.

Unlike the default update, cache_version will eliminate the extra connection to the web server to obtain "Modification-Date" and "Content-Length" of the cache_archive. This will speed up performance in most cases.

Security

Although sticky applets are cached locally, they will still conform to the security policy defined by its original codebase and signer.

Known Limitations

  • Both HTTP/HTTPS can be used with applet caching. However, cache_version must be used when HTTPS is the protocol because HTTPS in Java Plug-in uses a browser native API, and in some cases the browser native API does not return information like Modification-Date and Content-Length properly. As a result, using HTTPS without cache_version may force the cache_archive to download each time the applet is loaded.
  • Caching of the JAR files specified in the manifest's Class-Path variable using Java Plug-in's cache is currently not supported.
  • JAR files should either be listed in archive or cache_archive, but not both.
  • The path specified in the cache_archive must be a relative URL to the applet's codebase. Full URLs are not supported in cache_archive.