Cache key fragments from extracted variable for Response cache

Not applicable

Hi,

I have a requirement to create response cache key based on a variable in the JSON payload (request) . Using extract policy assigned the value to a variable and tried to use that in the KeyFragment. However its not reflecting in the cachekey. I use request.uri and the variable to create the key.

Is it possible to use an extracted variable as KeyFragment ?? Appreciate the help.

0 2 873
2 REPLIES 2

Hi Tom (@tomfransdavis),

Yes, you can use a variable extracted and assigned from Extract Variable Policy in ResponseCache Policy's CacheKey.

It goes like this in the ResponseCache Policy

    <CacheKey>
        <KeyFragment ref="request.uri" type="string"/>
        <KeyFragment ref="acceptType" type="string"/>
    </CacheKey>

In the above code, acceptType is a variable that is extracted from Extract Variable Policy

I suggest you check the Variable in tracetool whether it has been read and assigned properly. Also once verify the syntax of KeyFragment in the ResponseCache Policy

Please refer to ReponseCache from Apigee docs

Thank you Aswin