Home


7.1 DynaCache FAQs


Do I have to write any Java code to start caching objects?

No. DynaCache loads and processes the cachespec.xml file and starts caching without the need for any developer code. Many objects in WebSphere Commerce will automatically appear in the cache without any effort from the system builder. Developers can use DynaCache APIs if they wish, but it is not necessary.


Do I have to restart the server if I change the cachespec.xml?

No. DynaCache continues to monitor the file and automatically implements updates. It will work out what to do with the previous cache entries and remove them if required.


Can I still cache parts of a page and avoid caching the personalized bits so that I get at least some benefit from caching?

Yes. You can nominate an entire page for caching with exclusion instructions that omit any parts you do not want (using the do-not-cache command). The parts that are excluded are always executed by the application server and DynaCache will assemble the response page from both the cached and executed parts. The design of personalized fragments and the impact on caching is an important consideration for the Web site designer.


What is the best way to serve static content in WebSphere Commerce?

WebSphere Commerce serves static content directly through the Web server. An alias is created in the httpd.conf file during the instance creation to point to the stores directory in the following fashion:

Alias /wcsstore C:\WebSphere\AppServer\profiles\demo\installedApps\ WC_demo_cell\WC_demo.ear/Stores.war

All static content gets picked up directly on the Web server, and the application server only handles dynamic requests. If the Web server resides on a separate machine, the assets are copied over to the Web server.


What types of servlets and JSPs does DynaCache support most effectively?

Caching a simple presentation JSP file gives moderate performance gains.

Caching a servlet that requests large amounts of information from EJBs or databases reduces WebSphere Application Server and database loading and the number of network interactions.

Caching servlets that pull information from outside WebSphere Application Server produce the biggest performance gains.


DynaCache caches the JSP and servlet output. Does this mean it caches the HttpServletResponse object only?

Not quite. DynaCache caches the output of the servlet, that is, what is written to the response.getWriter() method. Unless your cachespec.xml file expressly prohibits this, DynaCache also caches "side effects" of the servlet's execution, like setting cookies and headers, including and forwarding to other servlets, and setting content type and character encoding.


Is this an "in memory" cache, or an "on disk" cache? Does it use the Java heap?

Both. DynaCache resides primarily on the Java heap. This keeps it in memory. However, DynaCache also supports the use of virtual memory, which we call Hash Table On Disk or HTOD.

The HTOD subsystem is used for overflow situations and to provide support for very large caches. It is an optional capability. Cache entries will also be offloaded to disk upon server shutdown and can be reused when the server is restarted.

Note that the effect of heap fragmentation and garbage collection is always a consideration when caching memory objects.


Can I influence what goes into the memory cache and what will overflow to disk?

Yes. Each cachespec entry has a priority value. DynaCache shunts lower priority items to the disk cache if the memory cache becomes full.

DynaCache also uses a LRU (Least Recently Used) algorithm to assist in selecting candidates to move. The priority is essentially the number of free passes an entry can have to stay in the cache when the LRU algorithm is looking for cache entries to evict. The bigger the number, the higher the priority to remain in memory. Recent changes have been made to provide even greater control over the memory and disk. Refer to the section What is new in v6 of DynaCache.


Does the DynaCache need an external cache for caching?

No. DynaCache does not require an external cache to be present for caching. It will, however, extend the abilities of such caches to include caching certain servlet and JSP files.


What are the security implications of using the DynaCache?

DynaCache does all the processing within the Web container after the security processing completes. Within the application server, there are no extra security problems to be considered.

However, when using an external cache, security risks change dramatically. Caches outside of WebSphere Application Server do not undergo security processing. It is important not to store sensitive data in an external cache. Anyone with JNDI namespace access can look up a cache instance and examine the contents of the cache.


What happens if cache data becomes stale?

You can use dependency IDs and invalidation rules that will automatically evict stale cache entries. This book describes in detail how to go about planning, configuring and implementing invalidation.


What about clusters? Does DynaCache work in a clustered environment?

Yes. DynaCache provides Distributed Replication Support (DRS) for distributing cached entries across a cluster.


Does each node in a cluster have its own disk cache? Can I use network attached storage devices to share the disk cache for all members in the cluster?

No. You cannot do this. DynaCache keeps a per node, "in memory" index of all items that are located on the disk, which would break if you attempted to share disk cache files across a cluster. The index would have to be shared across all cluster members, but for now there is no support for such a concept.


I have a very large catalog that I am thinking of caching. I can't fit it all into memory so how much disk space will I need?

The approximate guide for computing your disk cache space is:

page size x number of entries = disk size


Would a SAN improve the performance for a disk cache?

Yes.


I have read that there is an option to allow the persisting of the memory cache to disk on an application server shutdown. What impact will saving the cache have on shutting down the server?

Significant. Several minutes are added to the shutdown of a server if this option is used. DynaCache serializes Java objects to disk. Your cached objects must be serializable. Test this out beforehand.


Should I always use timeouts on my cache entries for invalidation?

No. Use timeouts sparingly! The best practice for invalidating a cached item and any dependent items is to invalidate only when .

We have found many examples of using timeouts throughout the cachespec. This often forces objects out of the cache that are still perfectly valid. The server wastes considerable time recreating the same objects in the cache, completely unnecessarily.

Use timeouts as a last resort, or if you know that your object will change within every timeout period.

+

Search Tips   |   Advanced Search