0

I am trying to write a cache store policy onto my apim. But for some reason, the cache is not clearing or dropped after the mentioned duration. Below is my code snippet. Code snip

I have a header with bearer token authorization and query parameter as emailid. Can someone help to understand why the cache is not dropped after the time?

<policies>
    <inbound>
        <base />
        <!-- Setup unique key -->
        <!-- store and retrieve cache -->
        <cache-lookup vary-by-developer="false" vary-by-developer-groups="false" allow-private-response-caching="true" must-revalidate="true" downstream-caching-type="none" caching-type="external" />
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
        <cache-store duration="30" />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>

1 Answers1

0

I have used your policy but changed caching-type="external" to caching-type="internal" and I am able to see that caching is stopped after the given period.

APIM Policy

<policies>
<inbound>
<base  />
<cache-lookup  vary-by-developer="false"  vary-by-developer-groups="false"  allow-private-response-caching="true"  must-revalidate="true"  downstream-caching-type="none"  caching-type="internal"  />
</inbound>
<backend>
<base  />
</backend>
<outbound>
<base  />
<cache-store  duration="30"  />
</outbound>
<on-error>
<base  />
</on-error>
</policies>

the cache is not clearing or dropped

In order to clear the cache value, you can use cache-remove-value policy. Refer ms docs to know about this policy.

After 30 sec, check the Trace to find out whether caching is dropped or not.

enter image description here

Please note when it is caching, you will get the message in Trace as message: cache lookup resulted in a hit

Ikhtesam Afrin
  • 897
  • 1
  • 1
  • 6
  • Thank you for the response. Since I am using the cache-lookup and cache-store, I don't know the key to give in the cache-remove-value. – Sruthy Varghese Jun 28 '23 at 13:17