Hi,
How can i skip the cache if the input request has been changed.
Solved! Go to Solution.
Seems like you are misunderstanding how the ResponseCache policy works. Please take a look at the documentation, specially how to work with cache keys.
In a nutshell, your cache keys needs to be uniquely defined and since in your case you want it to be based on the incoming JSON payload, you should consider using the Id and Data as cache keys accordingly. For example, you can have an ExtractVariable policy to set a variable:
<ExtractVariables name="EV-CacheKeys">
<Source>request</Source>
<JSONPayload>
<Variable name="id" type="string">
<JSONPath>$.Id</JSONPath>
</Variable>
</JSONPayload>
<VariablePrefix>ck</VariablePrefix>
</ExtractVariables>
And then reference this variable as your cache key fragment in the ResponseCache policy:
<ResponseCache continueOnError="false" enabled="true" name="RC-Test">
<DisplayName>RC-Test</DisplayName>
<Properties/>
<CacheKey>
<Prefix/>
<KeyFragment ref="ck.id"/>
</CacheKey>
<Scope>Exclusive</Scope>
<ExpirySettings>
<ExpiryDate/>
<TimeOfDay/>
<TimeoutInSec ref="">3600</TimeoutInSec>
</ExpirySettings>
<SkipCacheLookup/>
<SkipCachePopulation/>
</ResponseCache>
I hope this helps!
Seems like you are misunderstanding how the ResponseCache policy works. Please take a look at the documentation, specially how to work with cache keys.
In a nutshell, your cache keys needs to be uniquely defined and since in your case you want it to be based on the incoming JSON payload, you should consider using the Id and Data as cache keys accordingly. For example, you can have an ExtractVariable policy to set a variable:
<ExtractVariables name="EV-CacheKeys">
<Source>request</Source>
<JSONPayload>
<Variable name="id" type="string">
<JSONPath>$.Id</JSONPath>
</Variable>
</JSONPayload>
<VariablePrefix>ck</VariablePrefix>
</ExtractVariables>
And then reference this variable as your cache key fragment in the ResponseCache policy:
<ResponseCache continueOnError="false" enabled="true" name="RC-Test">
<DisplayName>RC-Test</DisplayName>
<Properties/>
<CacheKey>
<Prefix/>
<KeyFragment ref="ck.id"/>
</CacheKey>
<Scope>Exclusive</Scope>
<ExpirySettings>
<ExpiryDate/>
<TimeOfDay/>
<TimeoutInSec ref="">3600</TimeoutInSec>
</ExpirySettings>
<SkipCacheLookup/>
<SkipCachePopulation/>
</ResponseCache>
I hope this helps!
@pablosan Thanks for help. It worked.