Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to purge the Azure CDN to refresh any cached content?

I need to refresh the contents when I upload a new content to CDN. When the content change, it's important that the updated data is immediately available. But CDN caches and it is not reflecting immediately.

I referred to site 'https://msdn.microsoft.com/en-us/library/mt634451.aspx' and tried implementing the same. However, when I try to hit it, I get authorzation error.

{ "error": { "code": "AuthenticationFailed", "message": "Authentication failed. The 'Authorization' header is missing." } }

But the article does not give info abt what needs to go into Authorization header. Can someone pls help me here, on how to construct this authorization header? Pls let me know if you need more details.

Note: I checked the SO post 'How do I force Azure CDN content to be purged or invalidated?' and it does give link to the msdn link(same as above), but not about the authorization header.

like image 587
csharpnewbie Avatar asked May 03 '16 16:05

csharpnewbie


People also ask

How do I refresh the CDN cache?

Solution. To clear the cache for an image, log in to SPS and choose File > Invalidate CDN. When the dialog box appears, paste the full URL strings for the images you want to refresh into the text box. Then, press Submit.

What is purge in Azure CDN?

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. Tip. Note that purging only clears the cached content on the CDN edge servers.

How do I clear my Azure cache?

Open a Command Prompt window, enter iisreset, and then press ENTER. Delete the old cache root folder. By default, the cache root folder is located at %programfiles%\Azure DevOps Server 2019\Version Control Proxy\Web Services\VersionControlProxy\Data.

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 are using the right API, but are not using the Azure API Authentication via your application. You can find details on how to authenticate your API request along with a reusable code sample here: Azure Authentication - Authenticating any Azure API Request in your Application

Alternatively, you can purge using the new portal web interface. Find the details on how to do that here: Purge an Azure CDN endpoint

like image 154
Aman Sharma Avatar answered Sep 28 '22 18:09

Aman Sharma