0

I'm calling the backend logic app API and storing the data in cache. Even cache hit the success , outbound policy is calling the backend API and storing the data in the cache. Am i missing something here?

Code for policies used as below

<policies>
    <inbound>
        <base />
        <set-variable name="input" value="@(context.Request.Headers.GetValueOrDefault("flightno",""))" />
        <cache-lookup-value key="@((string)context.Variables["input"])" variable-name="flightno" />
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
        <set-variable name="ResponseResult" value="@(context.Response.Body.As<JObject>())" />
        <set-variable name="Key" value="@((string)((JObject)context.Variables["ResponseResult"])["flightno"])" />
        <set-variable name="payload" value="@((string)((JObject)context.Variables["ResponseResult"]).ToString())" />
        <cache-store-value key="@((string)context.Variables["Key"])" value="@((string)context.Variables["payload"])" duration="60" />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>
apaderno
  • 28,547
  • 16
  • 75
  • 90
user3656432
  • 3
  • 1
  • 4
  • You can refer to [Azure API Management - determine if response was served from cache](https://stackoverflow.com/questions/65422557/azure-api-management-determine-if-response-was-served-from-cache) and [API Management caching policies](https://learn.microsoft.com/en-us/azure/api-management/api-management-caching-policies) – Ecstasy Dec 13 '21 at 09:35
  • 1
    Thanks, I can see in trace that response is served from cache but it hits the backend logic app too . So I'm looking for solution how to avoid the backend call once cache hit the result. – user3656432 Dec 13 '21 at 23:14

0 Answers0