Hi All
Now i am using response cache policy through Get request but i want to if there is no records in DB then don't cache so what the condition putted in this ploicies.
Assumption: 1. As response cache policy is used to cache the backend response, I am assuming that you have configured your db as the target. 2. Your response is empty in this scenario.
Following condition can help you out: <Condition>response.content != "" and response.content != null<Condition>
If it doesn't work then please do let me know.
@Vinux Thomas , What do you mean no records in DB ? Are you talking about already cached record in Apigee Edge ? Which DB are you referring to ?
Hi @asagar,
I am talking about apigee backend,I have used in response cache policies but sometimes duplicates records stored in backend and also cached those records but I don't want duplicates records cached and even if there no data in backend then don't cached. so what condition have put in this policies. please guide me..
You can specify a condition under <SkipCachePopulation> tag of the Response Cache policy. This expression is evaluated at runtime and cache is populated (or not) based on the result.
@anshul,
I have putted this condition but i m getting server error and i unable to save to new revision also.
check xml code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ResponseCache async="false" continueOnError="false" enabled="true" name="Response-Cache-2"> <DisplayName>Response Cache 2</DisplayName> <Properties/> <CacheKey> <Prefix/> <KeyFragment ref="request.uri" type="string"/> </CacheKey> <Scope>Exclusive</Scope> <ExpirySettings> <ExpiryDate/> <TimeOfDay/> <TimeoutInSec ref="">300</TimeoutInSec> </ExpirySettings> <SkipCacheLookup/> <SkipCachePopulation> <Condition>response.content!= "" and response.content!= null</Condition> </SkipCachePopulation> </ResponseCache>
server Error:
Server Error. Error occurred while validation of bean Response-Cache-2.xml. Reason: - Schema validation failed. Cause : unexpected element (uri:"", local:"Condition"). Expected elements are (none). Line number : 17. Column number : 16. File name : Response-Cache-2.xml..
I am sorry if I confused you, condition won't be in the policy but should be applied on your step "Response-Cache-2" of response flow . eg:
<Step> <Name>Response-Cache-2</Name> <Condition>response.content!= "" and response.content!= null</Condition> </Step>
I see an error in the policy syntax. It should be like this (don't have the <Condition> tag within <SkipCachePopulation>) -
<SkipCachePopulation>response.status.code >= 400</SkipCachePopulation>
User | Count |
---|---|
5 | |
2 | |
2 | |
1 | |
1 |