使用 shell script 刪除 cloudflare 上的快取

1.先取得 domain name 的 ID

curl -X GET "https://api.cloudflare.com/client/v4/zones?name=網址" \
# -H "X-Auth-Email: test@gmail.com" \
# -H "X-Auth-Key: 7b9fb4xxxxxxxxxxxxxxxxxxxxxxxxxx" \
# -H "Content-Type: application/json" \

X-Auth-Email: 使用帳號
X-Auth-Key: API KEY 在 My settings 裡面可以查看

2.執行後會取得一連串的 json 字串、可以用線上 JSON檢視工具 直接看

3.取得後寫成shell script執行就好了

curl -X DELETE "https://api.cloudflare.com/client/v4/zones/e74b73xxxxxxxxxxxxxxxxxxxxxxxxxx/purge_cache" \
-H "X-Auth-Email: test@gmail.com" \
-H "X-Auth-Key: 7b9fb4xxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'