Cloudflare recently introduced Cache Response Rules, a rules engine that operates after an origin server responds but before content is written to Cloudflare's cache. Previously, Cache Rules operated only on request attributes. Cache Response Rules add a response phase that evaluates origin responses before they are cached.

According to the documentation, Cache Response Rules let users modify Cache-Control directives, manage cache tags, and strip headers such as Set-Cookie, ETag, and Last-Modified without changing the origin application, enabling finer control over cache behavior, improving cache hit rates, and simplifying CDN migrations. Alex Krivit, senior product manager at Cloudflare, and Anthony Turcios, former systems engineer at Cloudflare, write:

If you've ever been irked watching something that should easily sail out of cache get dragged back to the origin by a stray Set-Cookie or wrong Cache-Control, headers that are sometimes hard or impossible to strip or change on the origin itself, then Cache Response Rules is that fix, applied at exactly the right moment.

Source: Cloudflare blog

Cache Response Rules currently support three actions: removing headers that interfere with caching, managing cache tags, and modifying Cache-Controldirectives.

Cache decisions happen in two phases: request-time rules determine whether and how to look up content in the cache before contacting the origin, while the new Cache Response Rules operate after the origin responds, allowing response headers to modify caching behavior before the content is stored in the cache. When a visitor requests /static/app.js, Cloudflare checks its cache. If the file is not found, the request is forwarded to the origin, which returns the response. Among the response headers is a Set-Cookie header. Krivit and Turcios explain the challenge:

The asset that should have been cached at every Cloudflare data center is now uncacheable. Multiply that by every visitor, on every site, with the same accidental header, and you have a cache hit ratio that is leaking origin bandwidth, ruining performance, and driving infrastructure costs higher.

Cache Response Rules execute after Cloudflare receives a response from the origin but before it is stored in the cache, allowing users to modify cache-related headers, manage cache tags, and remove headers without changing the origin application.

While Cache Rules already existed to control how Cloudflare handles incoming requests and whether content should be retrieved from or stored in the cache, the new Cache Response Rules apply after the origin responds, enabling cache-related headers to be modified before the response is written to the cache. The team clarifies why they are complementary:

Cache Response Rules don't replace Cache Rules. Cache Rules decide whether, what, and how we cache on the request. Cache Response Rules get the final word on the how and whether, once the origin's response is seen by Cloudflare in a phase that didn't exist before.

Source: Cloudflare blog

On LinkedIn, Marcella dePunzio comments:

Improving cache performance often comes down to optimizing response behavior rather than adding more infrastructure. Giving teams greater control over caching policies at the edge helps increase efficiency, reduce origin load, and simplify application management without requiring code changes.

While some practitioners expressed skepticism about forcing caching if engineers incorrectly classify dynamic content as cacheable, Yuvdeep Singh, founder of Mission FinOps, adds:

Fixing origin mistakes at the edge, without waiting on app changes, is a big win.

Cache Response Rules are available across all Cloudflare plans.