Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force Azure CDN content to be purged or invalidated?

I have content that rarely changes that I want to serve over the Azure CDN for performance reasons. When the content does change, though, it's important that the updated data is immediately available. Ideally, I'd be able to set a long TTL but then proactively tell the CDN to expire content when I update it. How can I accomplish this? There is no cache invalidation or purge API right now, and I would rather not set a short TTL.

like image 810
John Waters Avatar asked Jan 06 '12 07:01

John Waters


People also ask

What is CDN purge in Azure?

CDN will immediately retrieve the new assets for the next client requests. Sometimes you may wish to purge cached content from all edge nodes and force them all to retrieve new updated assets. This might be due to updates to your web application, or to quickly update assets that contain incorrect information.

How do I clear Azure CDN cache?

Clean up resourcesSelect a CDN profile, then select the endpoint with the caching rules you want to remove. In the left pane under Settings, select Caching rules. Under Global caching rules, set Caching behavior to Not set. Under Custom caching rules, select the check box next to the rule you want to delete.

What does purge CDN cache mean?

Purging refers to the active removal of a resource from the cache without waiting for the predetermined cache expiry time. As soon as a user requests the purged resource, the CDN will cache a copy of the updated content from the origin server.

Does Azure CDN cache?

Azure CDN provides two types of caching rules: Global caching rules: You can set one global caching rule for each endpoint in your profile, which affects all requests to the endpoint. The global caching rule overrides any HTTP cache-directive headers, if set.


1 Answers

You can use the az cli to purge the cdn endpoint

az cdn endpoint purge is the root command

an example

az cdn endpoint purge -g group -n endpoint \
--profile-name profile-name \
--content-paths '/scripts/app.js' '/styles/*'

You can find more information on the cli command here

like image 182
Chief Avatar answered Nov 12 '22 19:11

Chief