TOC PREV NEXT INDEX




Managing the Caches


The CacheManager implements HTTP caching for HTML files, CSS stylesheets, JavaScript files, and images.

HTTP headers referring to caching are respected. For example, if the header contains "Pragma" and "no-cache", or "Cache-Control" and one of "no-cache", "no-store", "private" or "must-revalidate", the object is not cached. In addition, forms, Must Authenticate responses, and results from queries (unless they have an expiration time) are not cached. Cached objects always contain the "expires" and "max-age" information from headers.

By default, the CacheManager uses cached objects as long as they have not expired.

However, if you want to always use the most recent versions of objects, regardless of the expiry information, set the system property ice.net.alwaysRevalidate to true. This forces the HTTP system to determine if cached objects are valid (unchanged) before using them from the cache.

Although this ensures that the most recent versions are used, it also reduces the benefits of using the cache, because a connection to the server is used for each object that is checked.

Memory Cache

The MemoryCache caches resources that are loaded via HTTP in Java heap memory. This may include HTML, image, JavaScript, CSS files, etc. The MemoryCache is significantly faster than the FileCache as it doesn't require access to a hard drive. However, items in this cache do not persist across JVM sessions. If the MemoryCache fills to capacity (as specified by its maximum cache size), an LRU (Least-Recently-Used) algorithm is used to determine which cache entries should be removed from the cache to make room for new additions.

Using the MemoryCache is recommended if you do not explicitly require cached objects to persist across browser sessions and are able to allocate 500KB to 1MB of Java heap memory to this cache. The default maximum size for the MemoryCache is 1MB. It is not recommended to use a maximum size for this cache of less than 512KB to avoid constant cache flooding.

To enable detailed logging of the MemoryCache's activities, set the following system property:

ice.net.debug.memorycache=true
 

The ice.debug.trace=true or ice.debug.debug=true system property must also be defined for logging to be enabled.

File Cache

The FileCache writes all cached resources to the local file-system. This may include HTML, image, JavaScript, CSS files, etc. The cache files persist between JVM sessions, and they are read upon startup. As long as the items in the cache files have not expired, they are used. The FileCache may be significantly slower than the MemoryCache, depending upon the speed of the platform file-system. If the FileCache fills to capacity (as specified by its maximum cache size), an LRU (Least-Recently-Used) algorithm is used to determine which cache entries should be removed from the cache to make room for new additions.

Using the FileCache is recommended if you require cached objects to persist across JVM sessions and/or you are required to cache a large amount of content (> 1MB). The default maximum size for the FileCache is 5MB, although using a much larger FileCache is possible.

At startup, the FileCache must initialize itself and the time required to do this has a linear relationship with the number of entries in the cache. On most platforms this time is not significant but may be an issue on platforms with very slow file-systems.

To enable detailed logging of the FileCache's activities set the following system property:

ice.net.debug.filecache=true
 

The ice.debug.trace=true or ice.debug.debug=true system property must also be defined for logging to be enabled.



Copyright 2005. ICEsoft Technologies, Inc.
http://www.icesoft.com

TOC PREV NEXT INDEX