The policy allows user to reduce the number of calls made to the target server. The Cache Key identifies the part of message whose value is checked against the cache and response is returned from the target server only if it is not present in the local cache.
For example, a query parameter id can be used as cache key and once a request with id value as 10 is received by the proxy server, subsequent requests with value of 10 are picked from the cache rather than sending the call to target server.
Configuration
The properties that have to be configured to use the policy are described below.
Figure 1: Response Cache Policy Configuration attributes
Property | Description |
---|---|
Cache Name | Name of the cache in which the data has to be stored. |
Cache Key | Determines the attribute in request which identifies whether data has to be returned from Cache or from target server. Click the Edit button to configure Message Part Identifier. |
Time To Live | The number of seconds after which the cache entry expires and request is sent to target server and cached once again. |
Example
The request URL in this example is: http://localhost:1860/CurrencyConvetor/1.0/conversionrate?FromCurrency=INR&ToCurrency=USD
Configure Response Cache policy as per the below values:
- Cache Name: <Can be any value>
Cache Key:
- Time To Live: <can be any value>
When the request is sent for the first time, a cache with the specified name and cache key is created.
For subsequent requests with the parameter 'FromCurrency' and value 'INR', responses are picked from cache rather than sending the call to target server.