简体   繁体   中英

Azure API Management - determine if response was served from cache

We are using a <cache-lookup> policy in the <inbound> block (with an external Redis). Is it possible to execute a policy - to be specific, I would like to write a <trace> when the cache lookup was a hit and the response is served from cache?

Today we have this:

<inbound>
  <cache-lookup vary-by-developer="false" vary-by-developer-groups="false" downstream-caching-type="none" caching-type="external">
     <vary-by-query-parameter>xyz</vary-by-query-parameter>
  </cache-lookup>

Is something like this possible? (pseudo code)

  <choose>
    <when condition="cache-lookup == true">
       <trace>
         <message>This request is served from Redis cache!</message>
       </trace>
    </when>
  </choose>
</inbound>

According to some research, it seems there isn't a variable or status for us to judge if the request is served from Redis cache or the backend server. The <cache-lookup> policy wraps the functions connect with Redis, I don't think we can know where the request is served from. And as you mentioned the code is pseudo, I don't think the code <when condition="cache-lookup == true"> can work.

For this requirement, I think you can just ask azure develop team for this feature on feedback page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM