skip to content

As the lead for a shop on Cloudflare, what would you let Cache Rules cache, and who may change those rules and how?

level: principalimportance: should knowfreq 30%

answer

  1. allowlist, not hostname-wide
  2. a final bypass rule nobody removes
  3. who owns lifetimes: edge or origin
  4. roles and API token permissions
  5. response-side rules count too

basics

~20 s

Make caching an allowlist: eligible rules only for catalogue paths and static files, a final bypass rule for personal paths and session cookies, respect_origin on HTML. Limit who can edit Cache Rules, the Firewall role included, and review changes as code.

solid answer

~50 s

I would let the edge cache only enumerated anonymous content (catalogue pages and static extensions) through **Eligible for cache** rules, end the list with a **Bypass cache** rule for `/account`, `/cart`, `/checkout`, the API and the session cookie that only the platform team may move, and keep Edge TTL on `respect_origin` for HTML so application teams decide per response through `Cache-Control`. `override_origin` is allowed only on paths that can never be personal. For query strings, below Enterprise use Ignore query string only where parameters never change the page; on Enterprise prefer an allowlist key. On access: besides administrators, the dashboard **Firewall** role can edit Cache Rules and Cache Response Rules, so audit who holds it; deploy from CI with a token scoped to **Cache Rules Edit**; and treat **Cache Response Rules**, which can strip `private` or `Set-Cookie` before caching and win conflicts, as equally sensitive.

go deeper

for a junior

Recall that a broad Cache Rule can cache personal pages, so caching is limited to known anonymous paths.

for a middle

Explain why the bypass rule must come last and why respect_origin on HTML leaves lifetimes to the application.

for a senior

Show the controls that keep the policy true in production: role and token scope, rules as code, Trace before deploy, and a purge plan.

for a principal

Argue the trade between hit rate and leak risk, who owns lifetimes, and which signals would make you loosen or tighten the policy.

## The decision Every Cache Rule trades **hit rate and origin cost** against the risk of **serving one person's data to another**. A lead has to decide three things: which content the edge may hold, who decides each page's lifetime (the edge configuration or the application's headers), and who may change the rules and how changes are checked. There is no single right answer; the options below differ in where mistakes land. ## Options for who decides | Model | Who decides per page | Hit rate | Leak risk | What it needs | |---|---|---|---|---| | Edge decides: broad eligible rules with `override_origin` | Platform team | Highest | Highest; one broad expression caches personal pages | Perfect expressions | | Origin decides: eligible rules with `respect_origin` or `bypass_by_default` | Application teams via `Cache-Control` | Depends on header discipline | Low while personal pages send `private` | Header reviews in application code | | Hybrid allowlist: scoped eligible rules, a final bypass rule, `respect_origin` on HTML | Both, with the bypass as a backstop | High on catalogue pages | Lowest; two independent layers | A rule review process | For a shop I would choose the hybrid. ## A default-deny caching policy - **Allowlist eligible paths.** Eligible for cache only on catalogue paths (`/products/`, category pages) and static extensions, never a bare hostname, because Eligible for cache turns on Cache Everything for whatever it matches. - **A final bypass rule.** The last rule bypasses `/account`, `/cart`, `/checkout`, `/login`, the API and any request with the session or cart cookie. Because the last matching rule wins, nothing placed before it can re-enable caching for those requests. - **`respect_origin` on HTML.** Application teams then control product page lifetimes with `Cache-Control`, and a `private` or `Set-Cookie` keeps a page out even if it slips past the bypass rule's expression. - **Overrides by exception.** An `override_origin` Edge TTL only on versioned static files, with a named reviewer. - **Cache Deception Armor** on in the static-extension rule. - **Query strings.** Below Enterprise, Ignore query string only on paths where no parameter changes the page; on Enterprise, an allowlist such as No query parameters except `page` and `size`. - **Rule budget.** 10, 25, 50 or 300 rules by plan; a policy built from a few broad, well-tested rules fits every plan. ## Who may change the rules - **Dashboard roles.** Administrators can edit Cache Rules, and so can the **Firewall** role, which also covers Cache Response Rules. A security analyst given Firewall to tune the WAF can therefore change caching; grant it with that in mind. The **Cache Purge** role grants purging and reading zone settings, not rule editing. - **API tokens.** Cloudflare's documentation lists **Cache Rules Edit** with Account Rulesets Edit and Account Filter Lists Edit for managing Cache Rules through the API. Give that token to the deployment pipeline, not to people. - **Cache Response Rules.** Added in 2026, they act on the origin's response before caching: they can rewrite `Cache-Control` (remove `private`, add `s-maxage`) and strip `Set-Cookie`, and they take precedence over Cache Rules when settings conflict. Review them under the same policy, because one of them can undo the origin's protection. - **Rules as code.** Cache Rules live in the zone's `http_request_cache_settings` phase entry point ruleset. A `PUT` of that ruleset replaces its whole rule list, so a pipeline that owns the list must own all of it, and a hand-made dashboard rule is erased by the next deploy. ## A review checklist for every change 1. Can the expression match any path that renders personal data, now or after a planned route change? 2. Does the rule use `override_origin` or a Status Code TTL, and on which paths? 3. Is the bypass rule still the last rule? 4. Does a Cache Response Rule change `Cache-Control` or strip `Set-Cookie` on the same paths? 5. Has Cloudflare Trace been run on sample URLs (it needs an Administrator or Super Administrator), and have anonymous and signed-in requests been compared with `curl`? 6. Is a purge ready for the paths the change touches, in case it has to be undone? ## Signals to revisit the policy - The hit rate falls or origin load rises after a campaign adds new tracking parameters. - A leak or a broken sign-in is traced to the edge. - The zone moves to Enterprise, which opens allowlist keys and per-cookie keys. - Application teams ask for overrides often, which suggests the origin headers need work rather than more edge rules.

  • An application team wants a 1-hour override_origin Edge TTL on all HTML to cut origin load. How do you respond?
    I would ask them to send `Cache-Control: public, s-maxage=3600` on the pages that are truly anonymous, which `respect_origin` honours, rather than override the origin on all HTML. An override ignores `private` and strips `Set-Cookie`, so one personal route under the expression would be shared. If an override is still needed, it goes on an enumerated path list, ahead of the final bypass rule, with a named reviewer.
  • How do you keep a pipeline-managed Cache Rules list and emergency dashboard edits from fighting?
    Treat the pipeline as the only writer of the phase ruleset, since a `PUT` replaces the whole rule list and silently drops hand-made rules. Emergency edits are allowed in the dashboard but must be copied into the repository the same day, and the pipeline's next run is the check that they were.

  • Only account administrators can edit a zone's Cache Rules.
  • The Cache Purge role is enough to change how pages are cached.
  • A broad override_origin rule is fine as long as the origin sends private on personal pages.
  • Response-side rules cannot weaken caching safety because Cache Rules always win conflicts.
  • Updating the phase ruleset with PUT adds one rule and keeps the others.

Assumes Cloudflare as of 2026-10-10: Cache Response Rules arrived in March 2026 and can rewrite the origin's Cache-Control before caching, and the Firewall role can edit both Cache Rules and Cache Response Rules.