Response Cache with Post method

sidd-harth
Participant V

Hi guys, I have a proxy with one GETand POST methods. I used Response Cache policy.

Now the GET reuqests execute fine but POST request are not reflecting in the backend(BaaS).

If I remove the response cache then POST request gets updated in BaaS.

Is there a way/condition by which I can disable response cache while POST request?

Note- For POST I'm using an Ajax call outside Apigee.

@Maruti Chand

Solved Solved
0 3 1,198
2 ACCEPTED SOLUTIONS

adas
Participant V
@Barahalikar Siddharth

If you simply want to skip the cache lookup and cache population for POST calls, you can use SkipCacheLookupthe SkipCachePopulation elements in your cache policy. For example:

<SkipCacheLookup>request.verb = "POST"</SkipCacheLookup>

This would skip the cache lookup, similar thing can be done for SkipCachePopulation. You can refer to the docs here: http://apigee.com/docs/api-services/reference/response-cache-policy#element_reference for more details

View solution in original post

Not applicable

Hi @Barahalikar Siddharth , Put GET and POST in different flows and attach response cache in that particular flow or put a condition flow for response cache to be executed only in case of GET .

<Flow name="forecast">
            <Description/>
            <Request>
            <Step>
                <FaultRules/>
                <Name>responsecache-1</Name>
            </Step>
        </Request>
        <Response>
            <Step>
                <FaultRules/>
                <Name>responsecache-1</Name>
            </Step>
          </Response>
            <Condition>(proxy.pathsuffix MatchesPath "/forecastrss") and (request.verb = "GET")</Condition>
        </Flow>

or

<Step>
<FaultRules/>
<Condition>(request.verb = "GET")</Condition>
 <Name>responsecache-1</Name>
</Step>         

#1 is cleaner approach though .

View solution in original post

3 REPLIES 3

adas
Participant V
@Barahalikar Siddharth

If you simply want to skip the cache lookup and cache population for POST calls, you can use SkipCacheLookupthe SkipCachePopulation elements in your cache policy. For example:

<SkipCacheLookup>request.verb = "POST"</SkipCacheLookup>

This would skip the cache lookup, similar thing can be done for SkipCachePopulation. You can refer to the docs here: http://apigee.com/docs/api-services/reference/response-cache-policy#element_reference for more details

Not applicable

Hi @Barahalikar Siddharth , Put GET and POST in different flows and attach response cache in that particular flow or put a condition flow for response cache to be executed only in case of GET .

<Flow name="forecast">
            <Description/>
            <Request>
            <Step>
                <FaultRules/>
                <Name>responsecache-1</Name>
            </Step>
        </Request>
        <Response>
            <Step>
                <FaultRules/>
                <Name>responsecache-1</Name>
            </Step>
          </Response>
            <Condition>(proxy.pathsuffix MatchesPath "/forecastrss") and (request.verb = "GET")</Condition>
        </Flow>

or

<Step>
<FaultRules/>
<Condition>(request.verb = "GET")</Condition>
 <Name>responsecache-1</Name>
</Step>         

#1 is cleaner approach though .

sidd-harth
Participant V