Azure CDN Caching, Images not updating immediately?

I have created a CDN in Azure and I am building a .NET MVC Web Application that has the capability to upload an image to the CDN.

The initial upload works great and the image is available immediately after uploading.

If I upload again, with a different image, it does not update immediately from the web application. However, in my Azure portal, I can open the storage account container and see the new file available immediately.

No matter how much I refresh or restart the web application, it does not see the image until 5-10 minutes after the updated image upload.

It appears to me that this is something to do with the CDN caching in Azure. I have been searching for a solution for the past couple hours, and it seems there is very little documentation available online for this particular problem (which is strange, there is no way I am the first to have this problem, right?).

Also, under the Caching Rules in the CDN Endpoint in Azure, I can only see one drop down instead of the multitude of options I have seen elsewhere online, and none of the options seem to allow me to disable caching.

So, how can I get the updated images to display immediately?

Thanks!!

1 answer

  • answered 2018-06-25 05:40 Martin Brandl

    You are probably facing the browser cache. You can reload the site and the cache using STRG + F5 or use a different browser to ensure the image is updated within the CDN.

    A solution would be to add a query parameter to your image. E. g. https://yourdomain/storage/tmp.img?version=1234 Then you can update the version which will force the browsers to reload the image (but this would require a redeploy of your app).