Search code examples
azureazure-cdn

How to stop index.html being cached by Azure CDN


I am using Azure CDN to host a static website I am building.

It's great, other than the fact that when I update my web app the old page is cached and so still shown.

I have added the following Cache rule in the rules engine to put it to refresh every 60 seconds, however this does nothing and I still get the old content, the only way to get the new content is to go to an incognito browser.

Anyone have any ideas it's driving me crazy!

enter image description here

Here is a screenshot of the browser dev window when I hit the index.html page, I can't see any cache control headers here, I would think that the Azure CDN would/should be putting these on, is that incorrect?

enter image description here


Solution

  • The rule you are modifying controls the "internal max age". If a file shows up correctly in icognito mode, this rule is working fine. You have to set "external max age" to control the Cache-Control header.

    https://learn.microsoft.com/en-us/azure/cdn/cdn-verizon-premium-rules-engine-reference-features

    Looks like it is not Azure CDN which is caching index.html, it is your browser. Ensure that the Cache-Control header is returned correctly by using the developer tools.

    https://learn.microsoft.com/en-us/azure/cdn/cdn-manage-expiration-of-cloud-service-content

    https://learn.microsoft.com/en-us/azure/cdn/cdn-manage-expiration-of-blob-content