Configuring HTTP Responses Caching by Client
Caches
You can control caching of both static and dynamic HTTP responses by client (or proxy) caches using properties of the HTTP Provider and Web Container services. Based on the configurations you make with this procedure, the J2EE Engine sets the appropriate headers to the response to specify if the response is cached, or when the cached content expires.
Use the Visual Administrator tool to configure the cached HTTP responses expiration period:
...
1. Open the Properties tab of HTTP Provider Service running on the server process.
2. To set the period for storing static HTTP responses from the J2EE Engine in the ICM’s cache, set the appropriate value for the SapCacheControl property. The period is specified in seconds.
3. To set the period for storing static HTTP responses from the J2EE Engine in client caches, set the appropriate value for the CacheControl property. The period is specified in seconds.
The value of this property can be a comma-separated list of the following options:
Option |
Description |
A positive number. For example, the default value of the property is 86400. |
This number represents the expiration period (in seconds) of the cached resource. Depending on the HTTP version of the client, this number is used as follows: · For HTTP 1.1 clients the number is set as a value of the max-age directive of the Cache-Control HTTP header in the response. · For HTTP 1.0 clients the number is set as a value of the max-age directive of the Cache-Control HTTP header, as well as used to calculate the value of the Expires header.
If you use 0, then the response is not cached. In this case, the J2EE Engine still sets the Cache-Control header to the response with its max-age directive equal to 0. |
Any of the cache-response directives of the Cache-Control header described by the HTTP 1.1 specification in RFC2616. For example, private, public, no-cache, max-age directives. |
It is not allowed to use the max-age directive in combination with the positive number mentioned above as value of the CacheControl property. For example, valid values of the property are: · private,public,max-age=86400 · 86400,private,public A value of 86400,public,private max-age=2000 is not valid as it contains both the max-age directive and the number 86400. |
4. To add the new values to the list of properties, choose Update after editing each of them.
5.
To apply these
changes, choose
(Save
Properties).
You can configure the J2EE Engine to set the appropriate HTTP headers to the HTTP responses generated by servlets or JSPs so that they are never cached by shared and non-shared (client) caches. You can achieve this using the DisableDynamicResponseCaching property of the Web Container service. Use the Visual Administrator to configure it:
...
1. Open the Properties tab of Web Container service running on the server process.
2. To disable caching, set the value of the DisableDynamicResponseCaching property to true.
By default, the property is set to false. In this case, caching of the dynamic HTTP responses is determined by the specific implementation of the client caches (unless the servlet or JSP explicitly sets Cache-Control, Pragma, or Expires headers in the source code). Most HTTP clients (both HTTP 1.1 and HTTP 1.0 compliant) do not cache dynamic responses. However, it is possible that some old HTTP 1.0 clients still allow caching of such responses.
If you set the value of the DisableDynamicResponseCaching property to true, and if the servlet or JSP does not explicitly set any of the Cache-Control, Pragma, or Expires headers in their source code, then the J2EE Engine sets the Cache-control: no-cache and Pragma: no-cache headers (both for HTTP 1.1 and HTTP 1.0 requests) to the response. This way it guarantees that the dynamic response is never cached.
3. To add the new value to the list of properties, choose Update.
4.
To apply the
changes, choose
(Save
Properties).