Stale-While-Revalidate is a Cache-Control response directive that instructs a cache to immediately serve a stale (expired) cached asset to the client, while simultaneously and asynchronously revalidating the asset by fetching a fresh version from the origin server in the background. This mechanism ensures that subsequent requests receive the updated resource without the initial request suffering the latency of a blocking origin fetch.
Glossary
Stale-While-Revalidate

What is Stale-While-Revalidate?
A caching directive that prioritizes speed by serving immediately available content while updating it in the background.
This strategy is ideal for assets where speed is critical and slightly outdated data is acceptable, such as newsfeeds or social media timelines. The directive specifies a time window, e.g., Cache-Control: max-age=60, stale-while-revalidate=3600, meaning the cache serves fresh content for 60 seconds, then serves stale content for up to an hour while a background refresh occurs, effectively hiding server latency from the user.
Key Characteristics
The stale-while-revalidate directive is a fundamental building block for high-performance, always-available web architectures. It decouples the user experience from origin server latency.
Immediate Stale Delivery
The primary mechanism: when a cached object's Time-To-Live (TTL) expires, the CDN or browser does not block the request. It instantly serves the stale (expired) version to the user, eliminating origin latency from the critical rendering path. This ensures a cache hit is always served, even during revalidation, maintaining sub-millisecond response times.
Asynchronous Background Refresh
While the stale asset is being served, a separate, non-blocking request is triggered to the origin server to fetch the latest version. Upon successful retrieval, the stale cached copy is atomically replaced with the fresh one. This lazy revalidation populates the cache for the next user without penalizing the current one.
Cache-Control Header Syntax
The behavior is controlled by the Cache-Control HTTP response header. The directive stale-while-revalidate=<seconds> defines the grace period during which a stale response can be served. A typical configuration is:
Cache-Control: max-age=60, stale-while-revalidate=3600This allows a fresh response for 1 minute, and a stale response for up to 1 hour while a background refresh occurs.
Stale-If-Error Resilience
Often paired with stale-while-revalidate, the stale-if-error directive provides an additional safety net. If the asynchronous background refresh to the origin fails (e.g., a 500 error or network timeout), the CDN can continue to serve the stale asset for a defined period. This pattern creates a resilient, self-healing cache that masks complete origin outages from end-users.
CDN Implementation Variations
Major CDNs implement this strategy with different terminology:
- Fastly: Uses
stale-while-revalidatenatively with Surrogate-Key based purging. - Cloudflare: Supports the directive but also offers Always Online as a fallback.
- Akamai: Implements similar logic via Cache Prefresh behaviors in its property configurations.
- Varnish: Uses
beresp.stale_while_revalidatein VCL.
Impact on Core Web Vitals
By guaranteeing an instant response from cache, stale-while-revalidate directly improves Largest Contentful Paint (LCP) and reduces Time to First Byte (TTFB). It eliminates the latency tail caused by synchronous origin revalidation, making performance predictable and consistently fast for all users, regardless of traffic spikes.
Frequently Asked Questions
Clear, technical answers to the most common questions about the Stale-While-Revalidate caching directive and its role in modern web performance.
Stale-While-Revalidate is a Cache-Control response directive that instructs a cache to immediately serve a stale (expired) cached response to the user while asynchronously fetching a fresh version from the origin server in the background. The mechanism works in three phases: first, the cache serves the expired content instantly, eliminating origin latency from the user's critical path. Second, the cache initiates a non-blocking request to the origin to populate the cache with a fresh response. Third, the newly fetched response replaces the stale entry, ready for the next request. This directive is specified using the syntax Cache-Control: max-age=60, stale-while-revalidate=3600, where max-age defines the fresh window in seconds and stale-while-revalidate defines the grace period during which stale content can be served while revalidation occurs. The result is that users never wait on origin latency, perceiving consistently fast load times even during cache misses.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Understanding Stale-While-Revalidate requires a grasp of the broader caching ecosystem. These concepts define how content is stored, served, and invalidated at the edge.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us