Tuning servlet and JSP settings and code  Dynamic page caching

Chapter 5: Web Application Tuning

Understanding HTTP response caching options

EAServer supports caching of static content and servlet responses.


Static page caching

Caching of static content improves performance by eliminating file I/O. You configure the static page cache at the server level, as described in “Static Page Caching” in the EAServer System Administration Guide. Follow these guidelines to get the best performance from your cache:

When the cache is tuned, you can further improve the speed at which static page contents are served by disabling the HTTP request log (using the HTTP Config properties in the Server Properties dialog box). However, consider this option carefully as the request data can be helpful to diagnose performance problems that arise from changes in your configuration or user interests. For example, you may find newly posted content creates a large spike in the request pattern. The request log helps you identify popular content that you should add to the cache.


Servlet response caching

When caching is enabled for servlets and JSP Web components, EAServer checks for a cached response before calling the Web component. For servlets and JSPs that are called often, caching improves performance by skipping the processing required to produce the response. EAServer supports three mechanisms for response caching:

Which components should use caching?

Not all Web components should be cached. Caching the output of seldom-called Web components can sometimes reduce performance. If the cache is full, the rarely accessed output can bump more frequently accessed data out of the cache. On the other hand, if a servlet takes a long time to execute, you may still benefit from caching a servlet that it is not called as frequently as others, as long as there is sufficient space to cache the servlet. When the cache is too full to add or refresh a response, EAServer removes enough entries to make room, removing entries in least-recently-used order.

There is some overhead required to create and remove cache entries. If a Web component runs quickly, you may get better results with caching disabled, thus avoiding the overhead of maintaining additional cache entries and reserving more memory for the caching of other Web components.

To decide which Web components should be cached, review your request log patterns and Java profiling data (or timing trace data) to answer the following questions:

Based on these answers, you can determine which Web components are appropriate to cache and estimate the time that can be saved by caching them. For example, if you specify a timeout of 1 minute, the response takes 5 seconds to process, and the matching request occurs 4 times per minute, you can eliminate up to 15 seconds of processing time per minute (based on the fact that there are 3 cache hits per minute before the matching entry times out and must be recalculated).

How do I cache JSPs not defined in EAServer Manager?

To enable caching, you must define EAServer Web components for JSPs as well as servlets. Although a JSP can run when it is not installed as a Web component, you cannot enable caching unless you have defined a Web component that is mapped to the JSP. For example, to create and map a Web component for a JSP defined in myJSP.jsp:

  1. Create a JSP Web component called “myJSP”.

  2. Set the file property to “myJSP.jsp”.

  3. Create a Web application servlet mapping where servlet = “myJSP” and URL Pattern = “/myJSP.jsp”.

For more information, see “Creating and configuring JSPs in EAServer” in Chapter 24, “Creating JavaServer Pages,” in the EAServer Programmer’s Guide.





Copyright © 2005. Sybase Inc. All rights reserved. Dynamic page caching