Auto Clear Cache

Quick Question?
I Want to Clear the Full Website Cache Every 8 Hours.
I Have the Pro Plan, no specific URL, just the whole website.

What is the Simplest and easiest way to do this?

A cronjob that makes the API call:
https://api.cloudflare.com/#zone-purge-all-files

1 Like
  1. Just create a file (cfPurgeAll.sh) on a linux instance of you choice.
  2. write this into the file:
#!/bin/bash
ZONE_ID="YOUR_ZONE_ID"
EMAIL="[email protected]"
API_KEY="YOUR_API_KEY"

curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/purge_cache" \
     -H "X-Auth-Email: $EMAIL" \
     -H "X-Auth-Key: $API_KEY" \
     -H "Content-Type: application/json" \
     --data '{"purge_everything":true}'
  1. make it executable (chmod +x cfPurgeAll.sh)
  2. set a cronjob that executes it all 8 hours (0 */8 * * * /path/to/your/file/cfPurgeAll.sh)

Have fun

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.