How to Clear CloudFlare’s Cache

Run this command to clear all of CloudFlare’s cache:

curl -X DELETE “https://api.cloudflare.com/client/v4/zones/yourzoneid/purge_cache” -H “X-Auth-Email: your@email.com” -H “X-Auth-Key: yourglobalapikey” -H “Content-Type: application/json” –data ‘{“purge_everything”:true}’

where:
yourzoneid is your CloudFlare’s zone ID
your@email.com is the email address used to login to CloudFlare
yourglobalapikey is your CloudFlare’s Global API key

You should see the response similar to this:

{ “success”: true, “errors”: [], “messages”: [], “result”: { “id”: “123d56a89f123e5678901b34567890a2” } }

If you want to clear certain file only from the cache, just run the following command:

curl -X DELETE “https://api.cloudflare.com/client/v4/zones/yourzoneid/purge_cache” -H “X-Auth-Email: your@email.com” -H “X-Auth-Key: yourglobalapikey” -H “Content-Type: application/json” –data ‘{“files”:[“http://www.yourwebsite.com/somedirectory/filename.ext“],”tags”:[“some-tag“,”another-tag“]}’

P.S.
To find out your CloudFlare’s Zone ID, please see my previous post here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s