Configuration of this caching is done in the webapp.xml configuration file. You can create a sybase-webapp-config.xml using the development tool of your choice that adds the necessary caching attributes to the Web application’s configuration file.
To configure response caching for a servlet or JSP:
Modify the sybase-webapp-config.xml file for the corresponding Web application, located in the deploy\webapps\web_app_name\WEB-INF subdirectory of your EAServer installation. For example, if the Web application is named testwebapp, then you would edit the deploy\webapps\testwebapp\WEB-INF\sybase-webapp-config.xml file.
Add the cacheResponse attribute to the XML file, and the parameters that you want to use in the key as listed in Table 5-1.
Parameter name |
Description |
---|---|
timeOut |
Specifies the timeout in seconds for a cache entry; the default is 60; a value of 0 indicates no timeout. This property is cacheTimeout when specified in the <cacheResponse> Ant property. |
size |
Specifies the number of entries that can be cached. If not specified, the default is 1000. |
sessionLocal |
Includes the session ID from the request as part of the key. This allows session specific items such as shopping carts to be differentiated from each other. To enable the sessionLocal parameter, set it to true. The default is false. |
localeSensitive |
Allows you to include which languages are accepted as part of the key. The key is constructed from the list of locales in the request. The ability to include locale information is also included in the requestHeaders option, but for ease of use, it has been added as a separate option. Enable this option by setting it to true (the default). |
requestParameters |
Allows certain parameters from the request to be included in the key. The request contains a table of key-value pairs that are accessible from within a servlet or JSP from which the servlet developer can base the output of the servlet. This means that the same servlet, when given different parameters, may produce different output. Hence, two separate entries in the cache. You can specify as part of the cacheResponse attribute which attributes are to be included in the key. Since the attributes are stored as key-value pairs, both the key name and key value affect the key. The included parameters are listed in the requestParameters parameter of the cacheResponse attribute. To include all parameters, use an asterisk “*” (the default) in place of the list. |
sessionAttributes |
Allows certain session attributes from the session to be included in the key. Session attributes are stored in the key as key-value pairs. The attributes are specified by the sessionAttributes parameter of the cacheResponse attribute. To include all attributes, use an asterisk “*” in place of the list. In order to guarantee that the cache can store a session attribute, the type being stored needs to be serializable. The default is not to use sessionAttributes. |
requestHeaders |
Allows certain request headers from the request to be included in the key. For example, you could specify the date header to be included so that only entries in the cache whose date header matches the current date header are considered. Headers are case insensitive so the key is converted to lowercase. Headers are stored in the key as key-value pairs. The included headers are listed in the requestHeaders parameter of the cacheResponse attribute. To include all headers, use an asterisk “*” in place of the list. The default is not to use requestHeaders. |
Deploy (or redeploy) the Web application.