Syvizo

Cache Response



When to use

Use this policy when you want to use cached data to be sent in response instead of the request going to backend API. This should be used for the data that does not change frequently.



Details

Some API responses send data that does not change frequently and the same data is sent for multiple requests. When the cache is not used, the requests go to the backend API and the processing is done to get the response. This takes longer to send response and increase processing load on the backend API unnecessarily. 


This type of data can be stored in cache and sent in the response without sending the request to the backend API. Doing so improves the response times and saves on the resources for backend API.


Cache Response policy can be used to do this.


When this policy is configured in the flow, the cache is looked up based on the cache key input field for any request that is received. If the data is not found in cache, which will be the case for the first request, then the backend API is called and the response data is stored in cache. For any further requests with same key the data will be taken from the cache and sent in response till the time cache entry is valid (not expired).



Configuration

The configuration fields for the policy are:

[* Indicates a mandatory field]

Name *: Display name of the policy

Description: Description of policy

Enabled: Flag to indicate if the policy is enabled. If this field is not checked, the policy will be ignored at runtime and any fields from its output will contain a default initial value

Continue on Error: Flag to indicate that the flow should continue even if this policy throws an error

Cache Key: Key to identify data in cache. Value from this configuration field is used only if the input field “cacheKey” of the policy is not set

Expiry Date: Specifies the date when the policy should start The date format is dd/mm/yyyy

Expiry Time: Specifies the time when the policy should start. Time format is HH:mm:ss

TTL in seconds: Cache Time to live specifies how long after cache is valid after added. If present, this overrides Expiry date and expiry time. The cache will be removed after this time is elapsed and for any next request, the cache data will be re-populated with the response from the backend API call

Lookup Timeout in seconds: Maximum time the cache lookup will last. If the cache is not found within this time, the backend API call will be make and data will be retrieved from the backend API call.

Skip Cache Lookup: If this is checked, then the cache lookup will not be performed and the request will be sent to backend API. The data in response from the backend will be set in the cache and will overwrite the data if it is already present in cache.

Skip Cache Population: If this is checked, then the cache lookup is done and data is returned from cache if it is found. However, if the data is not found in cache and request is sent to backend API, then the data from the backend API response will not be added to cache.



Input fields

cacheKey: Key based on which cache lookup is done. This value overrides the value in configuration field “Cache Key”



Output fields

status: returns boolean true if the data is found in cache, otherwise returns false

Cache value: value found in cache