← Back
Vercel
Vercel CDN adds stale-if-error cache directive for resilient error handling
Vercel · featureapiperformance · vercel.com ↗

Stale-if-Error Caching Now Available

Vercel has expanded its Cache-Control directive support to include stale-if-error, giving developers more control over how their applications handle origin failures. When configured, this directive instructs the CDN to serve a previously cached response instead of returning an error to the client when the origin becomes unavailable.

How It Works

The stale-if-error directive specifies a time window (in seconds) during which stale cached content can be served when origin requests fail. Common failure scenarios include:

  • 5xx Server Errors (e.g., 500 Internal Server Error)
  • Network Failures and connectivity issues
  • DNS Resolution Errors

When the origin returns an error response and the directive is present, the CDN may serve the most recent cached version of the resource instead of propagating the error, allowing your application to continue functioning gracefully.

Getting Started

Developers can configure stale-if-error by adding it to their Cache-Control headers. For detailed implementation instructions and best practices, refer to the official documentation.

This feature is particularly valuable for applications that depend on multiple upstream services, providing an additional layer of resilience and improving user experience during transient failures.