Last active
July 20, 2024 20:36
-
-
Save lucien144/832e9493a4a599303df3200863daa450 to your computer and use it in GitHub Desktop.
Clear Cloudflare cache from command line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl -X POST "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}' |
Fantastic, I had to remove the X-Auth-Email and X-Auth-Key and replace with the authorization Cloudflare generated.
#!/bin/bash
curl -X POST "https://api.cloudflare.com/client/v4/zones/{$ZONE_ID}/purge_cache" \
-H "Authorization: Bearer {$API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
How to use this for custom purge? URL based
@bluegreen08 Most likely like this:
curl -X POST "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 '{"prefixes":["www.example.com/foo","images.example.com/bar/baz"]}'
@bluegreen08 Most likely like this:
curl -X POST "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 '{"prefixes":["www.example.com/foo","images.example.com/bar/baz"]}'
Thank you!!
@bluegreen08 Most likely like this:
curl -X POST "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 '{"prefixes":["www.example.com/foo","images.example.com/bar/baz"]}'
I realized this is tied to mu specific email. Is there a way to have this command and use a service token or service account?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you...