skip to content

Default Cache Behavior

By default Cloudflare caches static file extensions but not HTML, and honours the origin's Cache-Control. Interviewers ask how to read cf-cache-status and why a page shows DYNAMIC.

on this pageshow

explore

questions

5

On a site proxied by Cloudflare, which files does the edge cache by default, and why do HTML pages show cf-cache-status DYNAMIC?

level: juniorimportance: must knowfreq 75%

answer

  1. extension, not content type
  2. a fixed list of static types
  3. HTML and JSON left out
  4. decided before any cache lookup

basics

~20 s

Cloudflare caches by file extension: images, CSS, JavaScript, fonts, media, documents and archives, plus robots.txt. HTML, JSON and extensionless paths are not on the list, so those requests go to the origin without a cache lookup and show DYNAMIC.

solid answer

~40 s

By default Cloudflare decides cache eligibility from the URL's **file extension**, not the response's `Content-Type`. A fixed list (`css`, `js`, `jpg`, `png`, `webp`, `svg`, `woff2`, `pdf`, `mp4`, `zip` and dozens more, plus `robots.txt`) is eligible; HTML, JSON and extensionless paths such as `/articles/123` are not. For an ineligible request the edge skips the cache entirely and returns `cf-cache-status: DYNAMIC`. Origin headers do not change that: `Cache-Control: public, max-age=600` on an article page still yields `DYNAMIC`, because origin directives only govern responses that are already eligible. Caching HTML takes a Cache Rule that makes the path eligible. Development Mode or a bypass rule can also turn normally cached files `DYNAMIC`.

code

console · 5 lines
console
$ curl -sI https://news.example.com/articles/2026/budget-vote | grep -i cf-cache-status
cf-cache-status: DYNAMIC
$ curl -sI https://news.example.com/static/site.css | grep -i -E '^(cf-cache-status|age):'
cf-cache-status: HIT
age: 5120

go deeper

for a junior

Recall that the default is extension-based, that HTML and JSON are not on the list, and that DYNAMIC means the request never touched the cache.

for a middle

Explain that eligibility is decided at request time from the path, so origin Cache-Control cannot rescue an HTML page, and name Development Mode and bypass rules as other DYNAMIC causes.

for a senior

Show the diagnostic habit: read cf-cache-status per URL with curl, separate request-time DYNAMIC from response-time BYPASS, and confirm with Cloudflare Trace before touching origin code.

for a principal

Frame the default as a safety posture: nothing per-user is stored unless someone opts a path in, so any HTML caching must be an explicit, reviewed decision.

## How Cloudflare decides whether a request may use the cache When a hostname is **proxied** through Cloudflare (the orange cloud on its DNS record), every request passes through a Cloudflare data center before it reaches the origin. Before the edge looks in its cache, it makes a **request-time eligibility decision**: may this request be answered from cache at all? Without any Cache Rule, that decision rests on one thing: the **file extension at the end of the URL path**. Cloudflare's documentation states it plainly: Cloudflare caches based on file extension and not by MIME type, and the CDN does not cache HTML or JSON by default. The response's `Content-Type` plays no part in this first decision, because the decision is made before any response exists. ## The default list of cached extensions The list covers static, mostly immutable file types. Grouped by kind: | Kind | Examples on the default list | |---|---| | Styles, scripts and code | `css`, `js`, `ejs`, `class`, `jar` | | Images | `jpg`, `jpeg`, `png`, `gif`, `webp`, `avif`, `svg`, `svgz`, `ico`, `bmp`, `tif`, `tiff` | | Fonts | `woff`, `woff2`, `ttf`, `otf`, `eot` | | Audio and video | `mp3`, `mp4`, `webm`, `ogg`, `flac`, `mkv`, `avi`, `mid`, `midi` | | Documents | `pdf`, `doc`, `docx`, `xls`, `xlsx`, `ppt`, `pptx`, `csv`, `eps`, `ps` | | Archives and binaries | `zip`, `gz`, `bz2`, `7z`, `rar`, `tar`, `zst`, `iso`, `dmg`, `exe`, `apk`, `bin` | On top of the list, Cloudflare caches a site's `robots.txt` by default. Missing from the list are `html`, `htm`, `json`, `xml` and every **extensionless path**, such as `/articles/2026/budget-vote` or `/api/scores`. On a typical news site that means the stylesheet, scripts, photos and fonts are eligible, while every article page and every JSON feed is not. ## What `DYNAMIC` means Cloudflare reports its cache decision in the `cf-cache-status` response header. `DYNAMIC` means Cloudflare decided **at request time** that the request was not eligible, so it forwarded the request to the origin **without a cache lookup** and did not store the response. It is not a failed lookup (that is `MISS`), and it is not the origin refusing storage (that is `BYPASS`, a decision made later, at response time). So an article page showing `DYNAMIC` is the default working as designed. Every visitor's request for that page travels to the origin, which is why HTML time to first byte often barely moves after a site goes behind the proxy while images speed up dramatically. ## Why origin headers do not make HTML cacheable A common first fix is to send `Cache-Control: public, max-age=600` on article pages. Under the default configuration it changes nothing at the edge: the page still shows `DYNAMIC`. Origin cache directives govern **how long and whether** Cloudflare stores a response that is already eligible; they never make an ineligible request eligible. The header still travels to browsers, which may cache the page themselves. To have the edge store HTML or JSON, a team adds a **Cache Rule** that marks the matching paths as eligible for cache, and then must take care that per-user pages are excluded. Writing that rule is its own subject, covered with Cache Rules. ## Other reasons for `DYNAMIC` `DYNAMIC` can also appear on files that are normally cached: - **Development Mode** is on. It suspends the edge cache (and Polish) for three hours, and every response returns `DYNAMIC`. It does not purge anything; cached files are used again when it ends. - A Cache Rule with the **Bypass cache** setting matches the URL, or a legacy `Cache Level: Bypass` setting in a Configuration Rule or Page Rule does. - The request method is not `GET` or `HEAD`. Cloudflare turns a cacheable `HEAD` into a `GET` toward the origin, caches the full response and returns only the headers. ## Checking it yourself 1. Request the page and an asset with `curl -sI` and read `cf-cache-status` on each. 2. Repeat the asset request: the first request in a data center is `MISS`, later ones `HIT` with an `Age` header that grows. 3. If an asset you expected to be cached shows `DYNAMIC`, check Development Mode on the zone's Caching > Configuration page, then use **Cloudflare Trace** to see which rules match the URL. Reading `DYNAMIC` correctly saves hours: it points at the URL and the zone's rules, never at the origin's response headers.

  • An endpoint at /api/scores.json on a Cloudflare zone sends Cache-Control: public, max-age=30 and still shows DYNAMIC. Why?
    `json` is not on Cloudflare's default extension list, so the request is ineligible before any response arrives, and origin directives only apply to eligible requests. The edge needs a Cache Rule that makes the path eligible; the origin's `max-age=30` then sets the lifetime. Before adding one, confirm the feed is identical for every visitor, since the edge would serve one stored copy to all of them.
  • A Cloudflare zone's stylesheet that normally shows HIT now shows DYNAMIC on every request. What do you check?
    First, whether **Development Mode** is on: it suspends the edge cache for three hours and returns `DYNAMIC` for everything, without purging. Then whether a Cache Rule with **Bypass cache**, or a legacy `Cache Level: Bypass` Configuration Rule or Page Rule, now matches the path; Cloudflare Trace shows which rules apply to the URL. Finally, confirm the request method is `GET`.
  • Does an image served from /render?id=42 with Content-Type image/png get cached by default on Cloudflare?
    No. The eligibility decision looks at the URL's extension, and `/render` has none, so the request is `DYNAMIC` whatever `Content-Type` the origin later returns. Either serve the image under a path that ends in `.png`, or add a Cache Rule for that path.

A left-luggage office that only accepts the bag sizes printed on its sign: a newspaper is handed straight from the press to the reader every time, however loudly its wrapper says 'store me'.

  • Cloudflare caches every response by default unless the origin says not to.
  • Cloudflare decides what to cache from the response's Content-Type header.
  • Sending Cache-Control: public, max-age on HTML makes Cloudflare cache it by default.
  • DYNAMIC means Cloudflare looked in its cache and did not find the page.
  • Turning on Development Mode purges the zone's cache.
open as a page

In Cloudflare's cf-cache-status header, what do HIT, MISS, EXPIRED, UPDATING, BYPASS and DYNAMIC mean, and how do BYPASS and DYNAMIC differ?

level: middleimportance: must knowfreq 65%

basics

~20 s

HIT is served from cache, MISS is cacheable but fetched, EXPIRED is a stale copy refetched, UPDATING is stale served during background revalidation. DYNAMIC means ineligible at request time; BYPASS means eligible, but the origin's response could not be stored.

open as a page

How does Cloudflare set an eligible file's edge TTL from origin headers or defaults, and how does Browser Cache TTL change what browsers receive?

level: middleimportance: should knowfreq 50%

basics

~20 s

The edge follows the origin's s-maxage, max-age or Expires; with none, it uses status-code defaults (120 minutes for 200, 206 and 301). Browser Cache TTL, 4 hours by default, raises shorter origin lifetimes for browsers unless set to Respect Existing Headers.

open as a page

When an origin behind Cloudflare sends Cloudflare-CDN-Cache-Control, CDN-Cache-Control and Cache-Control together, which decides edge caching, and which reach the browser?

level: middleimportance: nice to knowfreq 30%

basics

~10 s

Cloudflare-CDN-Cache-Control decides first, then CDN-Cache-Control, then Cache-Control. Cloudflare-CDN-Cache-Control is never forwarded; CDN-Cache-Control and Cache-Control are, and Browser Cache TTL rewrites only Cache-Control.

open as a page