You are currently viewing Azure CDN – Purge selective contents from the endpoints

Azure CDN – Purge selective contents from the endpoints

In this short post, let’s quickly have a look at how to selectively purge the contents from CDN Endpoint.

Prerequisites

You would need to have an Azure account with an active subscription.  If you do not have it yet, you can create one for free. And then sign in to the Azure portal.

You might want to follow the steps mentioned in previous post to create the CDN profile, Azure web app and CDN endpoint for the web app.

Purge Cached Contents

In order to flush data from Azure CDN cache, let’s navigate to the CDN profile and open the Overview blade. Next, click on Purge button. This would open a new right side panel.

On the new panel, select the web app end point. Then you can either select purge all, or you can provide the relative paths under Content path list and then click on Purge to purge selective cached data.

Azure Portal: Purging cached contents from CDN Endpoint

If you select Purge All and then click on Purge button, it would purge all the cached data.

Selective Purging

In order to selectively purge, you can specify the paths under Content path list.

For example, let’s say, hypothetically, you want to purge all files at relative path /images/ and you also want to purge the /users/getall page (remember we have published the MVC application). We have to add these URLs in Content path list as shown below, then click on Purge.

Azure Portal: Selectively purge from CDN endpoint

Verification

This can be easily verified.

  • Add an Image under wwwroot/images folder. Publish the web app to Azure.
  • Then try to access image using URL https://demo-cdn-app-endpoint.azureedge.net/images/first.png. You should be able to see the image.
  • Replace existing image with new image and publish the web app to Azure.
  • If you try to access the image using same URL as above, you would be able to see the previous image, as CDN cache is not refreshed.
  • Now, lets selectively purge the data from path /images/ as explained in previous paragraph.
  • Give some time to synchronize the changes
  • Now, if you try to access the image using the same URL, you should be able to view the updated image.

I hope you found this information useful. Let me know your thoughts.

Leave a ReplyCancel reply