Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Response Cache policy for conditional flows

Question:

I am using response cache in conditional flow to cache data from a backend resource, reducing the number of requests to the resource.

I have 4 conditional flow and added in both request & response step as below.

<?xml version="1.0" encoding="UTF-8"?>
<Flow name="1">
   <Description />
   <Request>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Request>
   <Response>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Response>
   <Condition>(proxy.pathsuffix MatchesPath "/1")</Condition>
</Flow>
<?xml version="1.0" encoding="UTF-8"?>
<Flow name="2">
   <Description />
   <Request>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Request>
   <Response>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Response>
   <Condition>(proxy.pathsuffix MatchesPath "/2")</Condition>
</Flow>
<?xml version="1.0" encoding="UTF-8"?>
<Flow name="3">
   <Description />
   <Request>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Request>
   <Response>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Response>
   <Condition>(proxy.pathsuffix MatchesPath "/3")</Condition>
</Flow>
<?xml version="1.0" encoding="UTF-8"?>
<Flow name="4">
   <Description />
   <Request>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Request>
   <Response>
      <Step>
         <Name>Response-Cache-1</Name>
      </Step>
   </Response>
   <Condition>(proxy.pathsuffix MatchesPath "/4")</Condition>
</Flow>

==

<?xml version="1.0" encoding="UTF-8"?>
<ResponseCache async="false" continueOnError="false" enabled="true" name="Response-Cache-1">
   <DisplayName>Response-Cache-1</DisplayName>
   <FaultRules />
   <Properties />
   <CacheKey>
      <Prefix />
      <KeyFragment ref="request.uri" type="string" />
   </CacheKey>
   <Scope>Exclusive</Scope>
   <ExpirySettings>
      <ExpiryDate />
      <TimeOfDay />
      <TimeoutInSec ref="">300</TimeoutInSec>
   </ExpirySettings>
   <SkipCacheLookup />
   <SkipCachePopulation />
</ResponseCache>

==

What I was expecting:

##################

Cache the data from backend resource for each conditional flow & respond from cache( for subsequent requests).

What I am facing:

###############

See below error.

Response cache step definition Response-Cache-1 can not be attached more than once in the response path

We are using on-prem 4.15.04.

Tried few options to apply the policy in proxy pre/ & target post flow but see same error.

Let me know your suggestions if any one used response cache with conditional flows?

-Vinay

1 9 1,312
9 REPLIES 9