HTTP Cache stale-while-revalidate: Revalidation, Directives and Edge Status
How CDN edge caches use stale-while-revalidate, what Cf-Cache-Status values mean, and how to configure revalidation without blocking visitors.
This page summarises Cloudflare documentation on stale-while-revalidate, background revalidation, and the Cf-Cache-Status response header. It applies to traffic on Cloudflare’s CDN and to cacheable responses from Workers.
stale-while-revalidate: what it does at the edge
Section titled “stale-while-revalidate: what it does at the edge”stale-while-revalidate is a Cache-Control response directive your origin (or Worker) sets. It tells a shared cache that, for a limited time after the object’s freshness window ends, the cache may still serve the expired copy while it fetches or validates a newer one.
stale-while-revalidate is a Cache-Control directive set by your origin server that allows Cloudflare to serve an expired cached asset while a fresh copy is fetched from the origin.
— Cloudflare, Asynchronous stale-while-revalidate
Freshness (TTL) is how long the edge can serve an object without checking the origin; retention is how long the object may remain in cache before removal. After TTL expires, Cloudflare revalidates with the origin—unless you invalidate earlier. See Retention vs Freshness (TTL).
With stale-while-revalidate, revalidation at expiry can run in the background instead of making the first visitor wait on the origin. See Revalidation.
Asynchronous revalidation: why visitors see UPDATING instead of waiting
Section titled “Asynchronous revalidation: why visitors see UPDATING instead of waiting”Cloudflare’s stale-while-revalidate support is fully asynchronous. Behaviour changed from a model where the first request after expiry could block on the origin.
Previously, the first request for a stale (expired) asset in cache had to wait for an origin response, after which that visitor received a REVALIDATED or EXPIRED status. Now, the first request after the asset expires triggers revalidation in the background and immediately receives stale content with an UPDATING status. All following requests also receive stale content with an UPDATING status until the origin responds, after which subsequent requests receive fresh content with a HIT status.
— Cloudflare, Asynchronous stale-while-revalidate
That rollout sits on a newer cache proxy (Pingora), which Cloudflare describes as improving latency, cache retention, and RFC-aligned caching. See Pingora now powers Cloudflare’s cache.
Practical effects during async revalidation:
- Lower latency — no visitor waits on the origin while a stale copy exists in cache.
- Consistent experience — everyone gets the same cached body during revalidation.
- Reduced error exposure — the first request after expiry is not the only one exposed if the origin is slow or errors during refresh.
For synchronous validation (no stale serving), Cloudflare may still send 304 when the origin confirms the cached version is unchanged, with CF-Cache-Status: REVALIDATED in that path. See 3xx Redirection and Cloudflare cache responses.
Cf-Cache-Status: how to read HIT, UPDATING, REVALIDATED, EXPIRED, and STALE
Section titled “Cf-Cache-Status: how to read HIT, UPDATING, REVALIDATED, EXPIRED, and STALE”The Cf-Cache-Status (also referenced as CF-Cache-Status in docs) header tells you how the edge served the response. The meanings below come from Cloudflare cache responses and Invalidate cached content.
| Status | Typical meaning |
|---|---|
| HIT | Served from cache; content is fresh (or just refreshed after revalidation). |
| UPDATING | Entry was stale; edge served cache while refresh runs in the background (expected with async stale-while-revalidate). |
| REVALIDATED | Origin confirmed unchanged via conditional request (If-Modified-Since / If-None-Match); served from cache after synchronous validation. |
| EXPIRED | Stale entry; full fetch from origin (or Worker returned a new body). |
| STALE | Edge served an older cached copy because refresh failed (Worker error, timeout, or 5xx)—stale-if-error behaviour. |
| MISS | No usable cache entry. |
REVALIDATED is more common when stale serving is not allowed—for example when stale-while-revalidate is absent, or when directives such as must-revalidate or no-cache (with Origin Cache Control enabled) prevent serving stale content. See REVALIDATED.
UPDATING is the expected signal during asynchronous stale-while-revalidate; most revalidations that used to end in REVALIDATED may now show UPDATING then HIT instead.
How to enable stale-while-revalidate on origin and Workers
Section titled “How to enable stale-while-revalidate on origin and Workers”Origin Cache-Control header
Section titled “Origin Cache-Control header”To use async stale serving, the response must include stale-while-revalidate=<seconds> in Cache-Control. Cloudflare only serves stale content during revalidation when that directive is present. See Get started and Controlling stale behavior.
Example pattern from Workers cache configuration:
Cache-Control: public, max-age=600, stale-while-revalidate=60Fresh for 10 minutes; for up to 60 seconds after expiry, the edge may serve stale content while revalidating. See Use stale-while-revalidate for low-latency refreshes.
Workers can return the same headers from fetch; see Workers Cache.
Choose max-age and the stale window
Section titled “Choose max-age and the stale window”High hit rate and strong freshness pull in opposite directions. Background revalidation hides refresh latency, but a Worker still runs once per revalidation—it is not free. Two patterns from Choose TTL and stale-while-revalidate values:
- Mostly static content, small staleness tolerance — short
max-age(e.g. 60) and longerstale-while-revalidate(e.g. 3600): mostly HITs, occasional background refresh. - High-traffic “always from cache” —
max-age=0with largestale-while-revalidate: every request returns the cached body immediately and triggers background refresh; freshness drops if traffic stops.
Directives and settings that turn off stale-while-revalidate
Section titled “Directives and settings that turn off stale-while-revalidate”Cache-Control directives (RFC 9111 §4.2.4)
Section titled “Cache-Control directives (RFC 9111 §4.2.4)”If the response includes s-maxage, must-revalidate, or proxy-revalidate, Cloudflare disables serving stale content for stale-while-revalidate (and related stale-on-error behaviour in Workers). Expired entries are revalidated inline; you see EXPIRED or REVALIDATED instead of UPDATING. The same applies to stale-if-error in those cases. See Workers cache configuration and Directives that disable stale-while-revalidate.
Workaround for different browser vs edge TTL: do not rely on s-maxage for edge freshness if you want stale-while-revalidate at the edge. Use max-age plus stale-while-revalidate, and set a separate edge TTL with Edge Cache TTL in Cache Rules, or use CDN-Cache-Control patterns where documented.
With Origin Cache Control enabled, no-cache also forces revalidation before use. See Origin Cache Control.
Always Online causes Cloudflare to ignore stale-while-revalidate and stale-if-error per Revalidation.
Cache Rules: Serve stale content while revalidating
Section titled “Cache Rules: Serve stale content while revalidating”You can override origin intent with Serve stale content while revalidating in Cache Rules settings. When serving stale during refresh is disabled, Cloudflare will not serve stale content while fetching the latest version.
API property: serve_stale.disable_stale_while_updating (boolean). Example:
"action_parameters": { "cache": true, "serve_stale": { "disable_stale_while_updating": true }}stale-if-error: stale content when refresh fails
Section titled “stale-if-error: stale content when refresh fails”stale-if-error is separate from stale-while-revalidate. It allows serving a previously cached response when revalidation or origin fetch hits an error (5xx for origin CDN caching; Worker throw, timeout, or 5xx for Workers cache). See Origin Cache Control and Serve stale on error with stale-if-error.
Example:
Cache-Control: public, max-age=600, stale-if-error=86400For Workers, if you do not set stale-if-error and the response lacks s-maxage, must-revalidate, or proxy-revalidate, Cloudflare may serve stale on Worker error indefinitely (until purge)—resilient but can hide failures. Set stale-if-error=0 to surface errors quickly. See Serve stale on error with stale-if-error.
CDN-Cache-Control headers can set different stale-if-error windows for the edge vs other cache layers (e.g. Cloudflare-CDN-Cache-Control: stale-if-error=60).
On origin failure during invalidation, Cloudflare may still serve stale content beyond the stale-while-revalidate window when no stale-if-error limit is set—see Stale content during revalidation.
Invalidation, purges, and what visitors see
Section titled “Invalidation, purges, and what visitors see”Purging or invalidating cached content starts revalidation. With stale-while-revalidate, visitors may receive stale bodies for up to the directive’s window after invalidation (while refresh runs). Without it, requests wait for revalidation.
Expected outcomes after invalidation (simplified from Cloudflare’s verification table):
| Result | Cf-Cache-Status |
|---|---|
| Origin unchanged (304) | REVALIDATED, then HIT |
| Origin sends new content | EXPIRED, then HIT |
No ETag / Last-Modified |
EXPIRED, then HIT |
| Stale served during async revalidation | UPDATING, then HIT |
| Origin 5xx or unreachable | STALE |
| Entry gone | MISS |
Tiered Cache and concurrent requests can make edge status differ from origin logs; confirm with origin access logs. See Verify an invalidation.
To stop serving cached content entirely, purge rather than only invalidating. See Visitors receive stale content.
Common mistakes and debugging
Section titled “Common mistakes and debugging”UPDATING appears constantly
Section titled “UPDATING appears constantly”Usually max-age is shorter than your request rate, so every hit after expiry kicks off background revalidation, or you use max-age=0 with a large stale window. See Cf-Cache-Status: UPDATING appears constantly.
UPDATING never appears
Section titled “UPDATING never appears”All of the following must be true (Cf-Cache-Status: UPDATING never appears):
- A cached entry exists and is past
max-age. - The response includes
stale-while-revalidate=Nand the request is within N seconds after expiry (default window without the directive is 0). - The response does not include
s-maxage,must-revalidate, orproxy-revalidate.
If the stale window elapsed, behaviour reverts to inline revalidation (EXPIRED / REVALIDATED).
STALE appears unexpectedly
Section titled “STALE appears unexpectedly”STALE means the edge served cache because the refresh path failed. Check Worker errors, or unintended default stale-on-error behaviour. Log Cf-Cache-Status client-side—STALE is the signal that clients did not see the failure. Purge after fixing a bad deployment if an old broken entry keeps being served. See Cf-Cache-Status: STALE appears unexpectedly.
How to check this on your site
Section titled “How to check this on your site”-
Pick a cacheable URL whose origin returns
Cache-Controlwithstale-while-revalidateand validators (ETagorLast-Modified). Warm the cache untilCf-Cache-Statusis HIT (see Verify an invalidation). -
After
max-ageexpires (or after a cache invalidation), request the URL again and inspect response headers—for example with thecurlpattern in Verify an invalidation. Expect UPDATING during async revalidation if stale serving is allowed. -
Compare edge status with origin logs: confirm conditional requests and 304 responses when content is unchanged, as described in Invalidate cached content.
-
Review aggregate status codes in Common edge status codes if you are correlating cache behaviour with analytics; interpret 499 separately as client disconnects, not cache faults (Error 499).
-
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about.