CacheResponse

This policy uses a cache to store and retrieve a response from a back-end resource, reducing the number of requests to the resource.

Examples

In this example, a cache response policy is configured to cache responses for an hour based on the tenant, product name, and the request query parameters name and last name.

Although the tenant and product name are not mentioned as part of the key, these values are implied and automatically added by the system.

For example:

<cacheResponse
        xmlns="http://www.infor.com/ion/api"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        name="cache-response-example" displayName="cache-response-example" enabled="true" version="1.0" >
        <userLevel>false</userLevel>
        <cacheKey>
                <prefix>acme</prefix>
                <keyFragment ref="request.queryparam.name"><keyFragment>
                <keyFragment ref="request.queryparam.lastName"><keyFragment>
                <keyFragment ref="context.my_variable"><keyFragment>
                <keyFragment>Infor<keyFragment>
        </cacheKey>
        <expireSettings>
                <timeoutInSeconds>3600</timeoutInSeconds>
        </expireSettings>
</cacheResponse>
 

In this example, reference is made to a variable in the context object. The context object is a shared dictionary of information that can be accessed from the policies.

Configuration

Element name Default Presence Type Multiplicity
userLevel false Optional boolean 0..1
cacheKey n/a Required string 1
cacheKey.prefix n/a Required string 1
cacheKey.keyFragment n/a Optional string 1..*
expireSettings n/a Required string 1
expireSettings.timeoutInSeconds n/a Required string 1

<cacheResponse>

<cacheResponse name="cache-response-example" displayName="cache-response-example" enabled="true" version="1.0">

Attributes:

Field name Description Default Presence
name Name of this policy instance. N/A Required

displayName

Optional
enabled Indicates if a policy is enforced or not. If set to false, a policy is turned off, and not enforced. true Optional
version Policy version. N/A Required

<userLevel> element

This flag indicates if the cache should be set at the user level.

<userLevel>true</userLevel>

<cacheKey> element

<CacheKey> constructs the name of the key for the response stored in the cache. The key is often set using a value from context variables or query parameters.

The prefix as well as at least one keyFragment is required.

<cacheKey>
     <prefix>acme</prefix>
     <keyFragment ref="request.queryparam.name"><keyFragment>
     <keyFragment ref="request.queryparam.lastName"><keyFragment>
     <keyFragment ref="context.my_variable"><keyFragment>
     <keyFragment>Infor<keyFragment>
</cacheKey>

<cacheKey.prefix> element

Sets a prefix for the cache key.

<cacheKey.keyFragment> element

Sets a key fragment that is concatenated as part of the cache key. The keyFragment can either be a literal string or a value retrieved from the context. Use the attribute ref to retrieve a value from the context.

Field name Description Default Presence
ref Reference to a value in the context. N/A Optional

<expireSettings> element

Configuration of cache expiration for the response.

<expireSettings>
        <timeoutInSeconds>3600</timeoutInSeconds>
</expireSettings>

<expireSettings.timeoutInSeconds> element

Contains the number of seconds a response should be cached.