Skip to content

Instantly share code, notes, and snippets.

@dukedorje
Created April 14, 2021 23:24
Show Gist options
  • Save dukedorje/07af17b05a6a658f0653cfac3c54718b to your computer and use it in GitHub Desktop.
Save dukedorje/07af17b05a6a658f0653cfac3c54718b to your computer and use it in GitHub Desktop.
Curl command to clear cloudflare cache with API Token
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE}/purge_cache" \
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{"files":["'$DEPLOY_URL'/index.html", "'$DEPLOY_URL'/manifest.json", "'$DEPLOY_URL'/asset-manifest.json", "'$DEPLOY_URL'/robots.txt"]}'
# Uses new API Token. You can give it only the power to purge caches
# Note the single quotes around $DEPLOY_URL -- this is to unquote the single quotes so it'll interpolate the variable properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment