Can ResponseCache UseAcceptHeader use a ref?

Not applicable

I would like to be able to define ResponseCache policy's UseAcceptHeader and UseResponseCacheHeaders settings using 'ref'. This would allow me to easily configure these settings with Product custom attributes, rather than having to hard-code the settings and then later have to redeploy the proxy to make changes.

I am able to use 'ref' for ExpirySettings.TimeoutInSec. I would have thought the other settings would accept 'ref'.

Does anyone have any good ideas for dynamically configuring UseAcceptHeader and UseResponseCacheHeaders?

0 3 151
3 REPLIES 3

These are boolean values, right?

One workaround might be to configure TWO versions of the ResponseCache policy, one with hardcoded true and one with false. And then use a Condition to wrap the policies in the flow, so that only the correct one gets executed.

<Flow name='whatever'> 
  <Request> 
    <Step> 
      <Name>ResponseCache-UseAccept</Name>
      <Condition>apiproduct.use_accept = 'true'</Condition>
    </Step>
    <Step> 
      <Name>ResponseCache-DontUseAccept</Name>
      <Condition>NOT(apiproduct.use_accept = 'true')</Condition>
    </Step>
     ...
 

Have you tried this?

Not applicable

Hi,

You can set the values from flow variables like:

<UseAcceptHeader>{flowvar}</UseAcceptHeader>

You would *think* that syntax would work, but I have found that unless the literal true is used, the accept headers are NOT appended to the cache key in the ResponseCache policy. Have you successfully used this syntax, such that your flowvar is set to true and the cache key has the values from the Accept and Accept-Encoding request headers?