Java Technology Home Page
Downloads, APIs, Documentation
Java Developer Connection
Docs, Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide

A-Z Index

The Source for Java Technology

Applet Caching/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 is correpsonding to the jar file in the cache_archive.

Applet caching update Algorithm 

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

  • The cache_archive has not been cached before, or
  • The "Modified-Date" 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 "Modified-Date" 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 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 applet deployer to use cache_version attribute. Applet caching will be updated if

  • The cache_version corresponds 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, it will still be conformed to the security policy defined by its original codebase and signer.

 

Known Limitations

  • Both HTTP/HTTPS could be used with Applet caching; however, cache_version MUST be used when HTTPS is the protocol. The primary reason is that HTTPS in Java Plug-in is supported by using browser native API, and in some cases, the browser native API doesn't return information like "Modification-Date" and "Content-Length" properly. As a result, using HTTPS without cache_version may force the cache_archive to be downloaded every 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, or it may confuse Java Plug-in.
  • The path specified in the cache_archive must be a relative URL to the applet's codebase. Full URL is not supported in cache_archive .


[ This page was updated: 02-Dec-99 ]

Products & APIs | Developer Connection | Docs & Training | Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
Feedback | Map | A-Z Index

For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.