You can configure a response caching policy for a managed API or custom API. The response caching policy defines how long API Manager stores API responses in a cache repository.
When response caching is enabled for an API, API Manager saves responses to invocations of the API in the cache repository. Responses differ based on the input parameters that the API consumer sends to the API during invocation. When API consumers invoke the API, API Manager attempts to use saved responses in order to reduce time and resources. If a matching response is found in the cache, API Manager returns the response from the cache instead of calling the Cloud Application Integration process.
API Manager supports node-wise response caching. For example, assume that when an API consumer invokes an API that uses response caching, the call is processed by node A. If the subsequent invocation of the API is also processed by node A, API Manager returns the response from the cache. If the subsequent invocation is processed by a different node, say, node B, API Manager calls the Cloud Application Integration process again and saves the response in the cache of node B.
API Manager deletes responses from the cache after the defined timeout. When you disable the response caching policy for an API, API Manager deletes responses from the cache for the API.
Before you configure a response caching policy for an API, note the following considerations:
•The response cache can store a maximum of 200,000 bytes per API response, and up to 50 responses for a specific API.
•You can configure a maximum timeout of 3600 seconds.
•API Manager validates the IP filtering rules and basic authentication policy of the API before it stores the responses.
•API Manager stores API responses to GET requests that contain URL query parameters and to POST requests that contain an HTTP request body.
•API Manager stores API responses only to API invocations that return HTTP status code 200 to 299.
•API Manager matches current invocations of the API to previous invocations by comparing the query string parameters and the body of the request. It does not match the HTTP headers sent to the API.
•For responses that contain an empty JSON response payload, API Manager stores the <jsonObject/> string in the cache instead of the response payload.
•API Manager ignores Cache-Control directives in response headers. For example, if the response header contains Cache-Control: no-store, API Manager ignores it and stores the response in the cache.
•API Manager stores API responses that contain the media types html, zip, excel, pdf, octerStream, or msWord with media type application/json. If you download such a response through your browser, the browser doesn't append the appropriate extension to the response. For example, the browser doesn't append the extension .zip to responses that contain a zip media type.
•API Manager does not cache images. That is, it doesn't cache responses that contain media types image/jpeg, image/png, and image/tiff.
Configuring an API-specific response caching policy
Configure a response caching policy for a managed API or custom API on the Policies tab of the API details window to define how long API Manager stores API responses in the cache.
1On the API Registry page, click to open the Actions menu of the API and select View Details.
The API details window appears.
2Select the Policies tab.
3In the Response Caching section, select Enable Response Caching.
4In Cache Timeout, enter a value between 1 and 3600, and then click Save.
To disable the response caching policy for the API, clear the option Enable Response Caching, and then click Save.