If you have command line access on a server, this should work. Just make sure the script has execute permissions for everybody. It’s not a good idea to store it in the cloud because it has your API key.
curl -X POST "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache" \
[email protected]" \
-H "X-Auth-Key: API_KEY" \
-H "Content-Type: application/json" \
I’m not sure if the syntax is perfect. The example had a lot more data for more URLs to purge.
There’s a Worker that can do a Purge Everything that executes if you hit a specific URL. You really need to get a “trained coder” to execute specialized functions such as this.
The following service worker example works as a proxy to the Cloudflare API, allowing you to purge cache for any zone within your Cloudflare account by just sending a request to
Easily purge cache upon deployment by calling the /__purge_cache endpoint through a webhook
No need to expose global API keys to third party (deployment) tools
You may want to add further limitations by purging cache by cache tags, limit the script to only …