Sunday, November 29, 2009

Applet Caching not working

If your applet always downloads the jar even though jar is cached, Make sure you have not disabled the URLConnection's caching via the API: URLConnection.setUseCaches and URLConnection.SetDefaultUseCaches.

ImageIcon's underlying mechanism for fetching the resource is a URLConnection. Calling URLConnection.setDefaultUseCaches(false), sets a "part of the static state of all URLConnections" which cause the JRE to ignore the cache and redownload the entire jar every time it accessed. Simply removing all instances of setDefaultUseCaches will solve the problem.

http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/applet_caching.html

0 Java Junction comments: