How to Set CloudFlare into Development Mode

Development Mode temporarily allows you to enter development mode for your websites if you need to make changes to your site. This will bypass CloudFlare’s accelerated cache and slow down your site, but is useful if you are making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right away. Once entered, development mode will last for 3 hours and then automatically toggle off.

Run the following command to set CloudFlare into Development Mode (disabling cache) for the next 3 hours:

curl -X PATCH “https://api.cloudflare.com/client/v4/zones/yourzoneid/settings/development_mode” \
-H “X-Auth-Email: your@email.com” \
-H “X-Auth-Key: yourglobalapikey” \
-H “Content-Type: application/json” \
–data ‘{“value”:”on”}’

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 the following:

{“result”:{“id”:”development_mode”,”value”:”on”,”modified_on”:”2016-07-29T03:12:44.569389Z”,”time_remaining”:10800,”editable”:true},”success”:true,”errors”:[],”messages”:[]}

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

Reference:
https://api.cloudflare.com/#zone-settings-change-development-mode-setting

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.

How to Find CloudFlare Zone ID

Currently you can’t find your CloudFlare Zone ID from the CloudFlare control panel. Run the curl command below to get your Zone ID and other details as well. Just change your@email.com with the email address used to login to CloudFlare. Also change yourglobalapikey with your CloudFlare’s Global API Key. You can get it from https://www.cloudflare.com/a/account/my-account.

curl -X GET “https://api.cloudflare.com/client/v4/zones” -H “X-Auth-Email: your@email.com” -H “X-Auth-Key: your-global-api-key” -H “Content-Type: application/json”

You will see the output similar to this:

{“result”:[{“id”:”123d56a89f123e5678901b34567890a2″,”name”:”website.com”,
……………………………………………………………….
……………………………………………………………….
……………………………………………………………….
“success”:true,”errors”:[],”messages”:[]}

Your CloudFlare Zone ID is the one displayed after id (in this example: 123d56a89f123e5678901b34567890a2).