rhocfsandbox.com

demo: cache MISS → HIT

a cloudflare cache rule caches /api/cache-hit at the edge for 300 seconds. the button below fetches it three times back-to-back and shows the cf-cache-status header for each. cold cache the first request is a MISS (the function runs). the next two should be HIT (served from the requester's colo without touching the function).

click a button…

# try from your terminal

curl -sI "https://rhocfsandbox.com/api/cache-hit" | grep -iE "cf-cache-status|age|cache-tag"

# repeat within 5min: expect MISS, then HIT
for i in 1 2 3; do
  curl -sI "https://rhocfsandbox.com/api/cache-hit" | grep -i cf-cache-status
done

# what's the rule

rule nameSITE_cache_hit_ttl
expressionhttp.request.uri.path eq "/api/cache-hit"
actionset_cache_settings · cache = eligible · edge TTL 300s · browser TTL 30s
cache-tagSITE_cache_demo (attached by the function; enables purge-by-tag)