Response Cache policy allows a user to reduce the number of calls made to the target server. The Cache Key identifies the message by verifying the value with the cache, thereby returning a response from the target server only if the message is not present in the local cache.
For example, a query parameter ID can be used as a cache key and once a request with ID value '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 the cache or from the 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 the request is sent to the 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 values below:
- 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 the cache rather than sending the call to the target server.