rhocfsandbox.com

demo: purge by cache-tag

/api/cache-purge-target is cached at the edge for 3600s and tagged SITE_cache_purge_demo. warm the cache with the button, then either purge from the dashboard (Caching → Configuration → Purge Cache → Purge by tag) or with the curl below. refresh: new value.

click a button…

# purge from your terminal (needs a purge-scoped api token)

# purge by tag (enterprise + biz zones only)
curl -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/purge_cache" \
  -H "Authorization: Bearer $CF_PURGE_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"tags": ["SITE_cache_purge_demo"]}'

# on lower plans, purge the exact url
curl -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/purge_cache" \
  -H "Authorization: Bearer $CF_PURGE_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"files": ["https://rhocfsandbox.com/api/cache-purge-target"]}'

# what's the rule

rule nameSITE_cache_purge_target
expressionhttp.request.uri.path eq "/api/cache-purge-target"
actionset_cache_settings · cache = eligible · edge TTL 3600s
cache-tagSITE_cache_purge_demo