Home | 2.7 Putting items into the DynaCache | 2.7.2 Java objects and the command cache


2.7.1 Caching servlets and JSPs

When the application server starts and a targeted servlet or JSP is called for the first time, no cached entry is found and so the service() method of the servlet is called. The DynaCache Web container intercepts the response from the service() invocation and caches the results.

The next time the servlet is called and a match is found in the caching rules engine, the cached results are returned and the service() method is not called. This avoids all of the processing that would have been done by the Servlet, resulting in a substantial performance boost.

If, however, there isn't a cache entry for this ID, the service() method is executed as normal, and the results are caught and placed in the cache before they are returned to the requestor.

DynaCache increases performance by bypassing the service() method call entirely whenever a cache hit occurs.

Servlets and JSPs are configured for caching via entries in the cachespec.xml. A servlet cachespec entry is designated by its URI path or by its class name. The classname option is more inclusive because it will catch any invocation of the servlet, regardless of any servlet alias mappings defined. So which option should you use? The answer is "it depends."

Usually, the servlet is cached by its alias, since different aliases often imply different processing operations. Determining whether to cache on URI or classname depends entirely on the application. In most cases, the cache entry for the servlet needs to be further qualified by additional inputs, such as the request parameters or values from the user session information. This is explained in the section on specifying cache entries.

+

Search Tips   |   Advanced Search