Cloudflare CDN cache purge using Postman or Curl command

There are various approaches we can follow to clear or purge CDN cache. As part of this blog we will try to clear cache with the help of Postman.

Before reading this topic please visit this link to get overall theoretical knowledge around dispatcher, CDN, SSL and how they combinedly works.

On very high level, CDN creates below type of folder hierarchy to cache static content and asset as soon as we hit any URL. Similarly, for cache clearance it will ask us to provide path to clear cache or a wild card entry to clear everything inside root folder.

Purge cache using using files/paths:

{
  "files": [
    "https://www.javadoubts.com/en"
  ]
}

Purge everything inside root folder:

{
      "purge_everything":true
}

Note: CDN will consider shortened and full path as separate file path such as https://www.practice.com/en and https://www.practice.com/content/practice/us/en. It will require to provide a exact file path to clear or purge cache.

{
  "files": [
    "https://www.practice.com/content/practice/us/en",
    "https://www.practice.com/en",
  ]
}

Clear Cache Using POSTMAN

To clear cache we require zone id and authorization bearer token from client team as shown below:

As part of postman, create a POST request and provide required URL as https://api.cloudflare.com/client/v4/zones/zone_id/purge_cache where zone_id will provide by CDN or client team.

Provide Authorization bearer token as part of headers and select content type as application/json

Clicking on send button will provide below success response:

{
    "success": true,
    "errors": [],
    "messages": [],
    "result": {
        "id": "asasads987977979fsfsf9779sfs97fs"
    }
}

Curl Command to purge CDN cache

We can use below curl command also to purge cache using POST method with the help of zone id and authorization code as shown below:

curl --location 'https://api.cloudflare.com/client/v4/zones/asaasasas87d89s97add7a97ds9a79ad/purge_cache' \
--header 'Authorization: Bearer s90a898da8da9d9d9a9d7a97da89aad' \
--header 'Content-Type: application/json' \
--data '{
    "purge_everything":true
}'

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan