I have a backend API service that requires bearer-token authorization, and it is fronted by Azure API Management. One particular endpoint returns a large dataset (at least 3MB in size) but the endpoint has no parameters so any given response is valid for all users.
I have an external Azure Redis Cache configured for this APIM instance, and I want to add caching to this one endpoint, with the response cached for ALL users (not per-user).
To start off, I'm trying to get this working on a different parameter-less endpoint that only returns a 3Kb response - when I get it working, I'll apply the policy to the 3MB+ endpoint.
I tried adding a simple cache-store/cache-lookup policy:
<cache-lookup vary-by-developer="false" vary-by-developer-groups="false"
downstream-caching-type="none" caching-type="external" />
But that didn't work, and the following cache-lookup trace message was displayed:
"Request contains Authorization header. Cache Lookup policy was not applied."
So, I had to add another parameter to the cache-lookup policy:
allow-private-response-caching="true"
When I did this, the cache-lookup ran, but the trace message showed it was a miss:
{
"message": "Cache lookup resulted in a miss. Cache headers listed below were removed from the request to prompt the backend service to send back a complete response.",
"cacheKey": "**************************************************************",
"cacheHeaders": [
{
"name": "Cache-Control",
"value": "no-cache, no-store"
}
]
}
However, the cache-store trace message said that the response would be cached:
"Response will be buffered during streaming and stored in the cache after it is received in full."
So I ran the trace again, but it resulted in another "cache miss". No matter how many times I run the trace, it always says the cache is a miss, but the cache-key is identical every time. The cache duration is 3600, so the response should be cached for an hour.
If the key isn't changing, why does each lookup always result in a miss?