Cloudflare Cache Response Rules: A Guide for Website Owners
Learn how Cloudflare Cache Response Rules change caching from origin responses, when they apply, how rules interact, and how to troubleshoot matches.
Facts that can change should include a source and check date. Benchmark claims should state the plan, region, method, and test period.
If you want Cloudflare to change caching behavior based on what your origin returns, use Cache Response Rules. Cloudflare evaluates these rules after receiving the origin response and before caching it. The relevant domain or subdomain must be proxied through Cloudflare.
What Cache Response Rules can do#
Cloudflare documents these uses for Cache Response Rules:
- Change
Cache-Controldirectives. - Add or modify cache tags for targeted purging.
- Remove response headers such as
ETag,Set-Cookie, orLast-Modifiedbefore caching. - Apply settings to both cacheable and non-cacheable responses.
These capabilities let a rule respond to attributes of the origin response rather than only to details of the incoming request.
Cache Response Rules vs. Cache Rules#
The two rule types operate at different points:
| Rule type | Evaluates |
|---|---|
| Cache Rules | Incoming requests |
| Cache Response Rules | Responses returned by the origin |
Choose Cache Response Rules when the condition or adjustment depends on the origin response. Cloudflare’s documentation describes Cache Rules separately for request-based caching decisions.
Rule order and conflicting settings#
Cloudflare states that Cache Response Rules take precedence when settings conflict, and that the last matching rule wins. Review rules that can match the same response so their order produces the intended result. A later matching rule can change the outcome established by an earlier one.
Creating a rule#
Cloudflare supports creating Cache Response Rules through the Cloudflare dashboard, API, or Terraform. Before creating one, identify:
- Which proxied domain or subdomain is in scope.
- Which origin-response attribute should trigger the rule.
- Which caching directive, cache tag, or response header should change.
- Whether the rule must also apply to responses that are not normally cacheable.
If removing a header, check that the change is appropriate for the application before applying it broadly. Headers such as Set-Cookie and ETag can affect how clients and intermediaries handle responses.
Troubleshooting a rule match#
Use Cloudflare Trace to check whether a Cache Response Rule matches a specific URL. This helps confirm that the URL reaches the expected rule conditions and that another matching rule is not determining the final behavior.
Cloudflare also notes that Workers and Response Header Transform Rules run after the caching decision. They therefore cannot change how a response is cached. If the required change concerns caching itself, configure it in Cache Response Rules and use Cloudflare Trace to investigate matching.
Sources
- Cloudflare: Cache Response Rules Checked 2026-10-22
- Cloudflare cache documentation Checked 2026-10-22