The policy allows user to reduce the number of calls made to the target server. The Cache Key identifies the part of the message whose value is checked against the cache and the 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 '10' as value are picked from the cache rather than sending the call to the 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 the 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.