Show TOC

Configuring HTTP Responses CachingLocate this document in the navigation structure

Use

You can control caching of both static and dynamic HTTP responses by client (or proxy) caches or by ICM using properties of the HTTP Provider and Web Container services. Based on the configurations you make with this procedure, the AS Java sets the appropriate headers to the response to specify if the response is cached, or when the cached content expires.

Procedure

Caching of Static HTTP Responses

Use the SAP NetWeaver Administrator tool to configure the cached HTTP response expiration period:

  1. To modify the properties of the HTTP Provider Service using the SAP NetWeaver Administrator, use the Java System Properties function. For more information, see Java System Properties .

  2. In the Services tab, select HTTP Provider Service.

    On the Extended Details tab page, a list of all service properties is displayed.

  3. Select the property that you want to modify and enter the new value in the Custom Value field.

    • To set the period for storing static HTTP responses from the AS Java in the ICM's cache, set the appropriate value for the SapCacheControl property. The period is specified in seconds.

    • To set the period for storing static HTTP responses from the AS Java 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 the value of the max-age directive of the Cache-Control HTTP header in the response.

    • For HTTP 1.0 clients, the number is the value of the max-age directive of the Cache-Control HTTP header, as well as used to calculate the value of the Expires header.

    Note

    If you use 0, then the response is not cached. In this case, the AS Java 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.

    Caution

    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. Choose Save Changes .

Caching of Dynamic HTTP Responses

You can configure the AS Java to set the appropriate HTTP headers to the HTTP responses generated by servlets or JSPs so that they are never cached by shared and nonshared (client) caches. The standard HTTP clients and browsers do not cache responses unless the server has specified this, using cache control headers. If you however want to prevent incorrect caching by specific clients or proxy server, you can achieve this using the DisableDynamicResponseCaching property of the Web Container service. Use the SAP NetWeaver Administrator to configure it:

  1. To modify the properties of the Web Container Service using the SAP NetWeaver Administrator, use the Java System Properties function. For more information, see Java System Properties .

  2. In the Services tab, select Web Container Service.

    On the Extended Details tab page, a list of all service properties is displayed.

  3. 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 C ache -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 AS Java 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.

  4. Choose Save Changes .