Skip to content

Stale responses

A stale response is a cached object that could be served by the page cache up to 12 hours outside of a resource’s set max-age while the page cache fetches an updated response from the origin to serve for future requests.

The page cache might return a stale response if:

  • An error occurred while establishing a connection with the server when attempting to retrieve a freshened resource.
  • A timeout occurred while establishing a connection with the server, while passing a request to it, or while reading the response header.

Stale responses ensure that intensely trafficked resources on a site continue to be served in a timely fashion. Stale responses can be identified by the X-Cache: STALE HTTP response header.

The stale object (i.e. the previously cached response for a request) can be served immediately by the page cache, and a background request will occur for a freshened resource to update the cache from the origin servers. If another request for the resource is received while the cache is still in the process of updating, the response will be served with a X-Cache: UPDATING HTTP response header.

If the origin server returns a 5xx response, the cached object will continue to be returned until the stale period has ended.

Once the cache is refreshed, any subsequent requests are served the fresh response until the max-age is reached, and the cycle starts again.

Last updated: June 03, 2024

Relevant to

  • Node.js
  • WordPress