Serve Stale Content limits on origin error codes and Cache-Control interaction
0 reputation · 11 Jun 2021, 09:25 UTC
Cloudflare's Serve Stale Content setting controls whether a cached response is returned when an origin is unreachable or returns an error, but the boundary between stale hits and fresh misses depends on both the error class and any origin Cache-Control directives. The feature separates background revalidation from origin failure handling, and directives such as stale-while-revalidate and stale-if-error can extend stale-serving windows independently of the cache rule toggle.
The exact behavior is unclear when an origin returns a 4xx status rather than a 5xx, because stale content is generally not served for client errors, yet a cached 404 may still be treated as a valid fresh asset. It is also uncertain whether a plan-level or Cache Rules toggle overrides, supplements, or is overridden by origin stale-if-error values, and whether the legacy Cache settings page and newer Cache Rules evaluate these directives differently. Behavior differences across Cloudflare plans add further uncertainty for operators designing a consistent stale-serving policy.
Under these conditions, does Cloudflare treat a cached 404 as a fresh response rather than a stale candidate, and do origin stale-if-error directives apply when the dashboard Serve Stale Content option is disabled? How should Cache Rules and legacy cache settings be reconciled to avoid conflicting stale-serving outcomes across plans?