Skip to content
AnswerWell geo Documentation

Research · 11 min read · Answerwell

Cache Rules: Edge TTL, Browser TTL, and Cache-Control Headers

How Cloudflare Cache Rules set edge and browser TTL, cache keys, and how Cache-Control headers interact with CDN caching.

This page summarizes Cloudflare documentation on Cache Rules and Cache Response Rules: how to decide what gets cached at the edge and in visitors’ browsers, how long assets stay fresh, and how HTTP cache headers combine with rule settings. The same HTTP caching ideas apply beyond Cloudflare; Chrome and Workers docs in the cluster describe Cache-Control behavior for origins and static assets.

Cache Rules vs Cache Response Rules: what each one changes

Section titled “Cache Rules vs Cache Response Rules: what each one changes”

Cache Rules match incoming requests and set eligibility (cache, bypass, or eligible for cache) plus settings such as Edge TTL, Browser TTL, cache key, and Origin Cache Control. Create them under Caching → Cache Rules as described in Create a rule in the dashboard.

Cache Response Rules match requests (including response fields) and act on the origin response before caching—for example modifying Cache-Control, stripping headers, or setting cache tags. See Create a rule in the dashboard and Cache Response Rules.

When both apply, precedence matters. Cloudflare documents that a Cache Response Rule’s set_cache_control can win over a Cache Rule’s Edge TTL:

Consider the following scenario: A Cache Rule sets Edge TTL to override_origin with a value of 7200 seconds (2 hours). A Cache Response Rule uses set_cache_control to set s-maxage to 3600 seconds (1 hour) with cloudflare_only enabled. The origin responds with Cache-Control: s-maxage=600. In this case, the Cache Response Rule takes precedence. Cloudflare caches the asset for 3600 seconds (1 hour) based on the s-maxage directive set by the Cache Response Rule, while visitors still receive the original s-maxage=600 from the origin because cloudflare_only is enabled.

— Cloudflare, Cache Response Rules

Cache Rules order: how matching rules combine

Section titled “Cache Rules order: how matching rules combine”

Unlike legacy Page Rules, Cache Rules are stackable: every matching rule can contribute settings, and for the same setting the last matching rule wins. Conflicts such as bypass versus eligible for cache also resolve to the last match.

Cache Rules are stackable. This means that multiple matching rules can be combined and applied to the same request. For example, if multiple cache rules match the same URL, then the features set in those cache rules will all be applied in order. If several matching rules set a value for the same setting, the value in the last matching rule wins.

— Cloudflare, Order and priority

Bypass cache vs eligible for cache: typical expressions

Section titled “Bypass cache vs eligible for cache: typical expressions”

To skip cache for logged-in or cookie-based traffic, match the cookie and set Bypass cache, as in Bypass Cache on Cookie:

  • Expression example: (http.host contains "example.com" and http.cookie contains "test-cookie")
  • Then: Cache eligibility → Bypass cache

For broad HTML caching, Eligible for cache alone caches all HTML including dynamic pages—visitors may see wrong content unless you narrow the match (cookies, paths, extensions). Cloudflare warns in Cache Level (Cache Everything).

Default caching when no rule overrides headers

Section titled “Default caching when no rule overrides headers”

Without an Edge TTL override, Cloudflare follows origin Cache-Control and Expires, and still caches some responses by status code when those headers are absent.

Cloudflare does not cache the resource when: The Cache-Control header is set to private, no-store, no-cache, or max-age=0. The Set-Cookie header exists. The HTTP request method is anything other than a GET.

— Cloudflare, Default cache behavior

HTTP status (no Cache-Control / Expires) Default edge TTL
200, 206, 301 120m
302, 303 20m
404, 410 3m
Other Not cached by default

Details align across Default cache behavior and Configure cache status code.

Edge Cache TTL: how long the CDN keeps a response

Section titled “Edge Cache TTL: how long the CDN keeps a response”

Edge Cache TTL is the maximum time Cloudflare’s network treats an asset as fresh. It is not exposed in response headers to clients. Minimum Edge TTL depends on plan (Edge and Browser Cache TTL).

In a Cache Rule, Edge TTL has three primary modes (Available settings):

Dashboard option API edge_ttl.mode Behavior
Use cache control-header if present, bypass cache if not bypass_by_default Honor Cache-Control if present; otherwise do not cache
Use cache-control header if present, use default Cloudflare caching behavior if not respect_origin Honor header if present; else use default edge TTL by status
Ignore cache-control header and use this TTL override_origin Fixed TTL from the rule; ignores response Cache-Control

Status code TTL lets you set duration per status (single code, range, or inequality). For those entries, Cache-Control on the response is ignored in favor of the rule TTL, similar to “ignore header and use this TTL.” Example workflow: Cache TTL by status code.

Edge Cache TTL Cache Rules also override Cloudflare-CDN-Cache-Control / CDN-Cache-Control edge directives (CDN-Cache-Control).

Browser Cache TTL: what visitors’ browsers store

Section titled “Browser Cache TTL: what visitors’ browsers store”

Browser Cache TTL caps how long browsers may reuse a response. Cache Rules can Bypass cache, Respect origin, or Override origin (browser_ttl modes in Available settings). Override only changes the Cache-Control header visitors see; it does not alter Cloudflare-CDN-Cache-Control / CDN-Cache-Control (CDN-Cache-Control).

Zone-level Browser Cache TTL under Caching → Configuration raises browser lifetime when origin max-age is lower than the zone setting, or when the origin sends no cache headers—but not when you choose Respect Existing Headers unless a Cache Rule sets otherwise (Set Browser Cache TTL, Edge and Browser Cache TTL).

Setting high Browser Cache TTL values means that the assets will be cached for a long time by users’ browsers. If you modify cached assets, the new assets may not displayed to repeat visitors before the Browser Cache TTL expires. Purging Cloudflare’s cache does not affect assets stored by a visitor’s browser.

— Cloudflare, Edge and Browser Cache TTL

For fingerprinted static files, origins or Cloudflare Pages _headers often use aggressive browser caching:

/static/*
Cache-Control: public, max-age=31556952, immutable

Chrome recommends long max-age plus immutable for versioned static resources (for example AI model files), with cache busting via URL changes when content updates.

Cache-Control and CDN-specific headers: who reads what

Section titled “Cache-Control and CDN-specific headers: who reads what”

Origins can split TTLs across origin cache, shared/CDN cache, Cloudflare edge, other CDNs, and browsers using standard and CDN-specific headers.

When no Cache Response Rule sets directives, Cloudflare evaluates CDN-Cache-Control or Cloudflare-CDN-Cache-Control; ordinary Cache-Control may be proxied without driving edge TTL in that mode (CDN-Cache-Control). Example from the same page:

Cache TTL (seconds) with sample headers
Origin 14400 (max-age=14400)
Network shared 84000 (s-maxage=84000)
Cloudflare edge 24400 (Cloudflare-CDN-Cache-Control: max-age=24400)
Other CDNs 18000 (CDN-Cache-Control: max-age=18000)
Browser 14400 (max-age)

Workers document header precedence at the edge:

When multiple cache headers are present, the most specific wins: cloudflare-cdn-cache-control — Cloudflare-specific, highest precedence. Consumed by Cloudflare and stripped from the response returned to clients. cdn-cache-control — standard header for CDN-only directives. Cache-Control — standard HTTP header.

— Cloudflare, Workers cache configuration

If a Cache Response Rule uses set_cache_control, those directives take precedence over origin CDN-Cache-Control / Cloudflare-CDN-Cache-Control (CDN-Cache-Control).

Surrogate-Control: when present, Cloudflare ignores Cache-Control for caching decisions even if Surrogate-Control has no directives (CDN-Cache-Control).

Origin Cache Control: strict RFC behavior at the edge

Section titled “Origin Cache Control: strict RFC behavior at the edge”

Origin Cache Control (OCC) tells Cloudflare to strictly follow origin Cache-Control (RFC 7234). Enterprise customers can toggle it per Cache Rule; Free, Pro, and Business have it on by default and cannot disable it globally (Origin Cache Control, Available settings).

Behavior diverges sharply for directives like max-age=0 and no-cache:

Directive OCC disabled OCC enabled
max-age=0 Will not cache Caches and always revalidates
no-cache Will not cache Caches and always revalidates
no-store Will not cache Will not cache

Full matrix: Origin Cache Control. Setting Cloudflare-CDN-Cache-Control forces OCC-on Authorization logic per RFC 7234 §3.2.

max-age, s-maxage, and stale-while-revalidate must be integers; floats are ignored and may cause bypass (Origin Cache Control behavior).

Cache key: splitting or merging cache entries

Section titled “Cache key: splitting or merging cache entries”

The cache key defines when two requests share one edge entry. Options include cache deception armor, cache by device type, query string handling (up to 100 parameters in custom keys), headers, cookies, host, and user signals (Available settings).

When URL normalization is enabled, we recommend also enabling Normalize URLs to origin, especially if you are setting custom Cache Keys or using cache by device type, which also modifies the Cache Key. This helps ensure the URL in the Cache Key matches the URL sent to the origin, preventing cache poisoning and ensuring consistent behavior.

— Cloudflare, Available settings

Practical examples: Cache by Device Type, Cache Everything while ignoring query strings, Custom Cache Key, Cache Deception Armor.

Section titled “Set-Cookie, ETags, and Cache Response Rule header stripping”

For cacheable requests, Set-Cookie behavior depends on OCC and whether Edge TTL is explicitly set (Interaction of Set-Cookie):

  • Default cache level + no OCC: Cloudflare may strip Set-Cookie and cache.
  • OCC on + Set-Cookie: no cache; Set-Cookie preserved (BYPASS).
  • Eligible for cache + explicit Edge TTL override or status code TTL: may strip Set-Cookie and cache.

Cache Response Rules set cache settings can strip ETag, Set-Cookie, or Last-Modified before cache evaluation (Available settings — Cache Response Rules). Stripping ETag or Last-Modified after rules apply disables Smart Edge Revalidation for that response.

By default Cloudflare may weaken or remove strong ETags when transforming compression. Respect Strong ETags in a Cache Rule enforces byte-for-byte validation (Respect Strong ETags, Using ETag Headers with Cloudflare). Safari video range requests are a known failure mode; Cloudflare recommends ordered rules for *.mp4: first enable respect strong ETags, then a second rule bypasses cache so ranges hit origin (MP4 videos on iOS and Safari).

Other Cache Rule settings (when you need them)

Section titled “Other Cache Rule settings (when you need them)”
Setting Purpose Limits / notes
Cache Reserve eligibility Persist large objects in Cache Reserve add-on Plan file-size limits still apply (Available settings)
Additional cacheable ports Cache on admin ports (Enterprise) Default ports often cache without this rule
read_timeout Origin read timeout between reads (Enterprise) Raise to mitigate HTTP 524
origin_error_page_passthru Serve origin error pages Boolean in rule API
respect_strong_etags Strong ETag validation Disables Rocket Loader, Email Obfuscation, Automatic HTTPS Rewrites when on
  • Non-cacheable HTML that looks static: mark paths (/static/), extensions (.shtml), or query flags (static=true) and use Cache Everything with Edge TTL override if origin sends no-cache (Customize cache).
  • Cloudflare Images Browser TTL: separate from zone Cache Rules; account or variant browser_ttl in seconds (1 hour–1 year) sets Cache-Control on image responses (Browser TTL for hosted images).
  • Cloudflare Pages: avoid extra caching on custom domains unless immutable hashed assets; deployments already cache at the CDN (Serving Pages).
  • Image optimization: source Cache-Control must allow at least ~1 hour public caching or transforms may warn cache-control is too restrictive (Images troubleshooting); Cache Response Rules can raise max-age at the edge.

Chrome DevTools performance guidance treats fonts, images, scripts, and styles with 200/203/206 and without no-store / no-cache / must-revalidate as candidates for ≥30 days cache lifetime where appropriate.

  1. Enabling Eligible for cache on / without filters — caches personalized HTML; add cookie or path negatives (Cache Everything example).
  2. Expecting purge to fix stale browser assets — Browser Cache TTL and long max-age survive edge purge (Set Browser Cache TTL).
  3. Rule order surprises — a broad bypass rule placed after a cache rule wins (Order and priority).
  4. 304 TTL ≠ 200 TTL — unnecessary revalidation storms (Configure cache status code).
  5. Assuming OCC off behaves like OCC on — no-cache and max-age=0 bypass cache only when OCC is disabled (Origin Cache Control).
  6. Large cookies in cache keys — raises latency; total request size must stay within Cloudflare limits (Available settings — Cache key).
  1. In the Cloudflare dashboard, open Caching → Cache Rules and confirm rule order, match expressions, and whether the last matching rule sets bypass or TTL you expect (Order and priority).

  2. Request a representative URL twice and inspect response headers (Cache-Control, CDN-Cache-Control, Cloudflare-CDN-Cache-Control, CF-Cache-Status) against your Edge TTL and Browser TTL choices (CDN-Cache-Control, Default cache behavior).

  3. In Chrome DevTools → Network, enable cache (disable “Disable cache” only when debugging) and confirm static assets show long max-age / immutable where intended; use the Size column to see disk cache hits (Chrome performance cache insight, DevTools preferences).

  4. Review Cache Analytics after changes and adjust rules using your cache performance goals.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.