brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Check the CF-Cache-Status header to see how Cloudflare handled a request

Cache
~/tips/tip-cloudflare-cf-cache-status-header

curl -s -o /dev/null -D - https://example.com/style.css | grep -i -E '^(cf-cache-status|age):'

The CF-Cache-Status response header says whether Cloudflare served a file from cache or from the origin.

If a site sits behind Cloudflare, the first question about a stale page is whether Cloudflare or the origin sent it. The answer is in one response header, and curl can show it.

curl -s -o /dev/null -D - https://example.com/style.css | grep -i -E '^(cf-cache-status|age):'

-D - dumps the response headers to stdout and -o /dev/null throws the body away, so this does a normal GET and prints only the two lines. This was not run against a live Cloudflare zone; the values below come from the Cloudflare documentation.

  • HIT: the file was found in Cloudflare’s cache.
  • MISS: the response was eligible for caching but not in cache yet, so it came from the origin.
  • EXPIRED: it was in cache but expired, so it came from the origin.
  • REVALIDATED: the origin confirmed the cached copy is unchanged, and the copy was served.
  • STALE: an expired copy was served because Cloudflare could not reach the origin.
  • UPDATING: an expired copy was served while the origin refreshes it in the background.
  • BYPASS: the request was eligible, but the origin response was not cacheable.
  • DYNAMIC: the asset was judged not cache-eligible, so there was no cache lookup.

The Age header tells you how long the file has been in Cloudflare’s cache. Cloudflare sets it on HIT, STALE and UPDATING, but not on MISS, DYNAMIC or BYPASS. To see a HIT, request the same URL twice, since the first request can be a MISS.

Responses Cloudflare generates itself, such as a redirect or a WAF block, show NONE/UNKNOWN.

Further reading: Cloudflare Cache: cache responses

Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it

More Cache tips Vary: Accept-Language Cloudflare Development Mode bypasses the edge cache for three hours fincore /var/lib/example/data.db npm cache verify fc-cache -f -v ~/.local/share/fonts All Cache tips (27) All topics

Link