Introducing Cache Response Rules
Key Points
- Runs after origin reply, before caching
- Strip or override headers like Set-Cookie and Cache-Control
- Improves cache hit ratio and reduces origin load
Summary
Cache Response Rules are a new rule type that run after an origin server replies but before Cloudflare decides whether to cache the response. They let engineers modify response headers at the edge (for example, strip Set-Cookie, override Cache-Control, or normalize ETag) so assets that should be cached are not accidentally forced back to origin. The result: higher cache hit ratio, fewer origin requests, and better performance without changing origin code.
Key Points
- Runs after the origin response and before the cache stores/serves content.
- Fixes common cache eligibility issues caused by response headers such as Set-Cookie, incorrect Cache-Control, and aggressive ETag behavior.
- Allows modifying or removing response headers to make responses cacheable at the edge.
- Reduces origin bandwidth and infrastructure load while improving latency for end users.
How engineers should use it
- Target rules to specific paths, file types, or content-types (e.g., /static/.js, image/).
- Common actions: remove Set-Cookie on static assets, override Cache-Control for CDN TTLs, strip or normalize ETag/Last-Modified to avoid revalidation thrash.
- Deploy in stages: start in a small region or on a subset of routes, verify behavior, then expand.
Monitoring & safety
- Monitor cache hit ratio, origin request volume, and latency after changes.
- Avoid caching responses with sensitive or user-specific data; ensure rules are scoped narrowly when needed.
- Keep an audit of rules and test invalidation/refresh behavior to avoid serving stale content.