You put a site behind Cloudflare, send Cache-Control: public, s-maxage=300 on your pages, and every HTML response still says cf-cache-status: DYNAMIC. Nothing is misconfigured. Cloudflare just never looked at your header.
Its default cache behaviour page says it directly: "Cloudflare only caches based on file extension and not by MIME type. The Cloudflare CDN does not cache HTML or JSON by default." Your s-maxage is only read after something has made the request eligible, and for HTML that something is a Cache Rule.
Here's how the pieces fit, checked against Cloudflare's docs and two live sites today.
What cf-cache-status is telling you
The statuses split into two groups, and the split matters more than any single value.
Decided at request time, before your origin answers:
-
DYNAMIC: "not eligible for cache at request time", so there was no cache lookup at all. Usually the URL isn't a default cached extension and no rule opts it in. A Cache Rule set to Bypass cache, or Development Mode (which suspends cache for three hours), also produces it.
Decided at response time, once the request was eligible:
-
MISS: eligible, not in cache yet, fetched from the origin. -
HIT: served from cache. -
BYPASS: eligible, but the origin response wasn't cacheable. Typical reasons areno-storeorprivate, aSet-Cookie,Vary: *, or aCDN-Cache-Control: no-store. -
EXPIRED: found in cache but stale, so fetched again from the origin. -
REVALIDATED: stale, but the origin confirmed with a conditional request that it hadn't changed, so the cached copy was served. -
UPDATINGandSTALE: stale copies served while the origin is being refreshed in the background, or can't be reached.
So DYNAMIC and BYPASS are different problems. DYNAMIC means Cloudflare never considered caching the page, and no header will change that: you need a rule. BYPASS means it wanted to, and your origin said no: the fix is in your app.
One more detail that trips people up: Cloudflare only sets Age on HIT, STALE and UPDATING. If you see age on a DYNAMIC response, it came from your origin.
The default extension list
The cached-by-default list has 56 extensions: images (jpg, png, webp, avif, svg, ico), fonts (woff, woff2, ttf, otf), css and js, media, archives, and documents like pdf, docx and csv. robots.txt is cached too. HTML and JSON aren't on it, and neither is an extensionless path like /blog/my-post.
That's why the same site can show HIT on its stylesheet and DYNAMIC on the page that loads it.
Live check 1: css-tricks.com
The header check on the homepage, trimmed:
cache-control: max-age=0, s-maxage=2592000
cf-cache-status: DYNAMIC
cf-edge-cache: cache,platform=wordpress
vary: accept,content-type,Accept-Encoding,User-Agent
x-cache: MISS
age: 0
Two curl -sI requests a few seconds apart:
cache-provider: CLOUDWAYS-CACHE-DE
cache-control: max-age=0, s-maxage=2592000
age: 0
x-cache: MISS
cf-cache-status: DYNAMIC
cache-provider: CLOUDWAYS-CACHE-DE
cache-control: max-age=0, s-maxage=2592000
age: 3
x-cache: HIT
cf-cache-status: DYNAMIC
The origin asks shared caches to keep the page for 30 days (s-maxage=2592000). The host's own cache (x-cache, cache-provider: CLOUDWAYS-CACHE-DE) does exactly that: MISS, then HIT with age: 3. Cloudflare sits in front of it and says DYNAMIC both times. That age belongs to the hosting cache, not to Cloudflare.
The cf-edge-cache: cache,platform=wordpress header is the one Cloudflare's WordPress plugin sends for Automatic Platform Optimization (APO). Cloudflare's APO docs say a working setup also returns cf-apo-via, and there wasn't one. So the plugin is saying "cache this", nothing on the Cloudflare side appears to act on it, and every HTML request travels to the origin, where a second cache answers it.
For contrast, a plugin stylesheet on the same site:
cache-control: public, max-age=31536000
age: 68309
cf-cache-status: HIT
.css is on the list, so it's cached. The check graded the homepage C, partly for Vary: User-Agent and for having no ETag.
Live check 2: nocache.dev (my own site)
I ran the same check on the site I built for this, and it has the same problem:
cache-control: public, max-age=0, s-maxage=300, stale-while-revalidate=60
cf-cache-status: DYNAMIC
Both curl -sI requests returned identical cache-control and cf-cache-status: DYNAMIC, with no age. Its hashed stylesheet went MISS, then HIT with age: 2:
cache-control: public, max-age=31536000, immutable
cf-cache-status: HIT
The origin header is fine. There's just no rule making HTML eligible, so the five-minute shared cache never happens. A second, quieter issue: Cloudflare's docs note that s-maxage implies proxy-revalidate, which disables stale-while-revalidate on Cloudflare. The stale-while-revalidate=60 there does nothing even once the page is cached. Cloudflare evaluates Cloudflare-CDN-Cache-Control, then CDN-Cache-Control, ahead of Cache-Control, so a separate CDN-Cache-Control: max-age=300, stale-while-revalidate=60 is the way to keep both.
Cache Rules, in three decisions
A Cache Rule is a filter expression plus settings (Free plans get 10). Three choices matter most.
1. Cache eligibility. Eligible for cache is what turns DYNAMIC into MISS/HIT for HTML. Bypass cache does the opposite and shows up as DYNAMIC.
2. Edge TTL, with three modes (API name in brackets):
- Use cache-control header if present, bypass cache if not (
bypass_by_default) - Use cache-control header if present, use default Cloudflare caching behavior if not (
respect_origin) - Ignore cache-control header and use this TTL (
override_origin)
For HTML, the first is the cautious choice: only pages your app marks cacheable get cached. respect_origin falls back to Cloudflare's default TTLs (120 minutes for a 200) when there's no header. override_origin ignores your app entirely, and on the Free plan the minimum Edge Cache TTL is 2 hours.
3. Browser TTL: respect origin, override origin, or bypass. This is what the browser is told, separately from the edge.
Via the API, a rule that makes HTML eligible but lets the origin decide looks like this (deployed to the http_request_cache_settings phase):
{
"expression": "(http.host eq \"example.com\" and not starts_with(http.request.uri.path, \"/admin\"))",
"action": "set_cache_settings",
"action_parameters": {
"cache": true,
"edge_ttl": { "mode": "bypass_by_default" },
"browser_ttl": { "mode": "respect_origin" }
}
}
The docs' own example uses a PUT on the ruleset, which replaces every rule in it. Read the existing rules first.
Bypass on cookie, and the rule order
Making all HTML eligible is how logged-in pages get served to strangers. Cloudflare's caution on the "cache everything" example says as much, and suggests excluding paths or checking for a cookie. The cookie version is a second rule with Bypass cache:
(http.host eq "example.com" and (http.cookie contains "wordpress_logged_in" or http.cookie contains "session"))
Order matters. Cache Rules stack, and for conflicting settings "the last matching rule wins". Put the bypass rule after the eligible one, or the broad rule overrides it.
A related trap with Set-Cookie on the response: with Eligible for cache and a header-respecting Edge TTL, Cloudflare keeps the cookie and doesn't cache, so you get MISS every time. With Ignore cache-control header and use this TTL (or a status code TTL), Cloudflare removes the Set-Cookie and caches the page. If that response was personalised for whoever got the session, everyone now sees it.
The Browser Cache TTL setting
Separately from rules, the zone-wide Browser Cache TTL on the Caching page defaults to 4 hours. Per the docs, Cloudflare overrides your Cache-Control or Expires when your value is lower than that setting, or when you send neither. A value set in a Cache Rule is ignored if your max-age is higher: it can only make browsers cache longer.
For HTML, that's the wrong direction. A max-age=0 meant to make browsers pick up deploys is lower than 4 hours. (Neither DYNAMIC response above had it rewritten, but I can't see those zones' settings.) Choose Respect Existing Headers, which the docs say stops Cloudflare overriding or inserting Cache-Control unless a Cache Rule sets it, or set Browser TTL to respect origin in the rule. Purging Cloudflare doesn't clear what's already in a visitor's browser.
Testing it
curl -s -D - -o /dev/null https://example.com/ | grep -iE 'cache-control|cf-cache-status|^age'
Run it twice. DYNAMIC both times: no rule matches. BYPASS: a rule matches and the origin says no. MISS then HIT with a rising age: it works. Then repeat with your login cookie and expect DYNAMIC.
The checks above came from nocache.dev, which I built. Its report pages identify the CDN and suggest a fix; for both sites here it said "Add a Cache Rule: Eligible for cache, Edge TTL respects origin s-maxage." For scripts, npx nocache-dev check https://example.com --json prints the same data, and there's a public API at https://nocache.dev/docs/api.
Top comments (0)