Revalidation and request collapsing
Revalidation is a caching mechanism that involves checking the of cached data before serving it to a client or user. If a cached object is no longer and Cloudflare receives a request for it, a request is made to the origin to revalidate the object in the Cloudflare cache.
Consider the following example scenarios.
One-thousand (1,000) requests arrive simultaneously at Cloudflare’s network, and the requested resource was in Cloudflare but cannot be served because its TTL configuration indicates it is no longer fresh. This means that the resource needs to be served from the origin server. In this case, one request will go to the origin to be revalidated, while the other 999 requests will be served from cache with the status of . This means that the resource, although expired, is served stale from Cloudflare’s cache, while the origin server is updating it. This behavior is defined by the directive in
cache-control. If you do not wish to serve stale content, set the directive to zero seconds,
One-thousand (1,000) requests arrive simultaneously at a single Cloudflare data center, and the requested asset is not in Cloudflare’s cache (a cache miss). These requests will use a cache lock to communicate with your origin. This means that only the first request will go to origin to fetch the asset. The remaining 999 requests wait for the first request to fetch the data, after which the response is to all the waiting requests. The cache lock ensures that Cloudflare only sends the origin one request at a time for a given asset from a location in Cloudflare’s network, preventing the origin from getting too much traffic.