Azure API Management and output cache policies

I am writing this post because I was one day confronted with the situation when I had to move a whole bunch of HTTP Services to be called via Azure API Management. These services were serving mobile calls from both iOS and Android devices.

All nice and well but the problem I got was that some of these services should have their response cached for a period of time so that the apps would not call them every single time. The API management does indeed provide some settings to set caching but for some reason whenever the apps would call any of the cached services the “Cache-Control” header was always set to private instead of public as it was desired ( here is some interesting reading about Cache-control headers ).

So in this picture you can see how I was setting the caching in the Azure API Management :

Cached Operation

This was not enough. The cache was still private and not having a max-age value until I specifically inserted in the caching policy of that specific operation.

cachingPolicies

Hope this post helps someone. Leave a message if it did ;).

 

 


Comments

One response to “Azure API Management and output cache policies”

  1. Richard Hauer Avatar
    Richard Hauer

    Hi Alin, I understand that checkbox controls caching in the APIM itself, it is not supposed to adjust the caching headers of the asset. This just prevents the APIM proxy from going back to the origin for a certain period. Are you suggesting that the APIM was not caching after checking the “cachable” box, and that APIM was going back to your origin service anyway?

    Also – have you found any means of programatically evicting an item from the cache. It seems like they are using ARR to power the APIM service, and I know that doesn’t have a means of evicting items.