Tutorial :client-side applet caching?



Question:

Is it possible to cache a jar file used in an applet on the client-side? I am reading conflicting information:

  • it appears you can set a "cache" parameter with <object> + <param>

However -

  • I guess <applet> is the preferred way to go? I have not seen any sort of cache attribute for the applet tag.

Does anyone know of a way to cache jar files? There is a third-party library that is needed in my applet that is ~130kb in size.

thanks


Solution:1

According the the java plugin development documentation You can use the cache_archive, cache_version and cache_archive_ex parameters to cache your applets and third party libraries.

This is the usage:

<OBJECT .... >  <PARAM NAME="archive" VALUE="a.jar">  <PARAM NAME="cache_archive" VALUE="b.jar, c.jar, d.jar">  <PARAM NAME="cache_version" VALUE="0.0.0.1, 0.0.2A.1, 0.3D.22.FFFE">  <PARAM NAME="cache_archive_ex" VALUE="applet.jar;preload, util.jar;preload;0.9.0.AC1, tools.jar;0.9.8.7F">  </OBJECT>  

Also, there is a warning in this page:

.jar files specified with the archive attribute also get cached in this sticky cache.

In case this applet caching mechanism does not work for you, check whether it has been disabled elsewhere, such as through the APIs. Make sure you have not disabled the URLConnection's caching via the API: URLConnection.setUseCaches and URLConnection.SetDefaultUseCaches


Solution:2

Applets are cached by default on the clients machine, there's little need to override it IMO.

Even with the cache mechanism you are not guaranteed that the file will be cached. The cache control seems to be more about version control IMO, but I disabled it after noticing that the progress bar behaviour was strange when using it.

For version control I simply load the jar from a URL containing the version number.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »