Configuring page caching for servlets and JSPs

Use EAServer Manager to enable caching for your servlets and JSPs. To enable caching for JSPs, you must have a Web component defined for the JSP in EAServer Manager. To configure default values for the Web component caching properties, see “Configuring Web application page caching properties”.

StepsTo configure page caching for a servlet or JSP:

  1. Expand the Web application folder and highlight the servlet or JSP.

  2. Choose File | Web Component Properties.

  3. Select the Caching tab.

  4. Check Enable Cache. By default, page caching is disabled.

    NoteThe first time you configure page caching for a Web component, the page caching property values default to the same as those in the Web application.

  5. To replace the current property values with those in the Web application, select Get WebApp Settings.

  6. To include the output from all the pages that the Web component includes or forwards requests to, select Cache Entire Tree. For more information, see “Caching an entire tree”.

  7. Optionally, edit the timeout value, and enter the parameters that you want to use in the key as listed in Table 5-1.

    Table 5-1: Page caching properties

    Parameter

    Description

    Cache Timeout

    Enter the number of seconds to keep the Web component’s content in the cache; the default is 600; a value of 0 indicates no timeout. The timeout value is stored in the com.sybase.jaguar.servlet.cache.timeout property.

    Session Local

    To include the session ID in the key, select this option; by default, it is not included. The session ID can identify session specific items, such as shopping carts. The value is saved in the com.sybase.jaguar.servlet.cache.use-sessionid property.

    Locale Sensitive

    Select to include the accept-languages header in the key; by default, it is not included. The value is saved in the com.sybase.jaguar.servlet.cache.locale-sensitive property.

    Request Parameters

    To include request parameters in the key, enter the parameter names as a comma-separated list. To include all the request parameters, select the Enable All box; it is selected by default. A single servlet can produce different responses based on which parameters it receives. A key that includes the request parameters allows different responses from the same servlet to be cached separately. The request parameters are saved in the com.sybase.jaguar.servlet.cache.request-parameters property.

    Session Attributes

    To include session attributes in the key, enter the attributes as a comma-separated list. To include all the session attributes, check the Enable All box. The session attributes list is saved in the com.sybase.jaguar.servlet.cache.session-attributes property.

    Request Headers

    To include request headers in the key, enter the header names as a comma-separated list. For example, if you include the date header, EAServer looks for cache entries whose date headers match the request’s date header. The request headers list is saved in the com.sybase.jaguar.servlet.cache.request-headers property.

    Message Topics

    For a key that includes the number of times a message has been published to a particular topic, enter the message topic. To use this as a key parameter, the message service must be configured; for details, see Chapter 31, “Using the Message Service.”

    This option is useful when a servlet constructs its response based on the values in a database table. A database trigger can be used to call the message service and publish a message to the topic each time the database table is updated. When a servlet or JSP is requested, EAServer can call the message service’s getStatistics method to get the total number of messages published to the topic and compare the value to those in the cache entries. The message topics are stored in the com.sybase.jaguar.servlet.cache.message-topics property.