Request collapsing, also called request coalescing, is a caching technique in which a proxy or CDN node that receives many simultaneous requests for the same uncached object sends only one request to the origin and serves the single response to every waiting client. In content delivery across the Internet, it is a primary defense against the thundering herd problem, where a cache miss on popular content would otherwise multiply into thousands of identical origin fetches.
The technique matters most at the moments when caches are weakest: right after a cache purge, when an object expires, or when new content is published and requested by a large audience at once.
How request collapsing merges concurrent cache misses
When the first request for an object misses the cache, the edge node creates a pending fetch entry keyed by the cache key. Every further request with the same key that arrives while the fetch is in progress is placed in a waiting queue instead of triggering its own origin request. When the origin responds, the node stores the object if it is cacheable and fans the response out to all queued clients.
The mechanism depends on an accurate cache key. Two requests collapse only when the node can be certain they would receive the same response, so the key must include every attribute that changes the content, such as the host, path, relevant query parameters and headers listed in the Vary header.
Collapsing also applies to revalidation. When a stale object carries an ETag or Last-Modified validator, the node sends one conditional request, and a 304 Not Modified reply refreshes the cached copy for every waiting client. The benefit therefore covers both full misses and expiry checks, which is where much of the origin traffic on busy sites originates. The size of the saving grows with the number of clients requesting the object within the fetch window, so the effect is strongest for popular, short-lived content such as live scores, manifests for streaming video and news homepages.
The following table summarizes the sequence for one popular object after expiry.
| Moment | Edge node action | Origin load |
|---|---|---|
| First request misses | Opens one origin fetch | One request |
| Further requests arrive | Queue behind the pending fetch | No additional requests |
| Origin responds | Stores object and answers all waiters | Fetch completes |
| Later requests | Served directly from cache | None until expiry |
Collapsing at the edge, the shield and the origin
Request collapsing can occur at several layers, and its effect compounds across tiers. A single edge node collapses requests from its own clients, but a CDN with hundreds of points of presence could still send one request per node. Tiered caching and an origin shield add a second collapsing layer, so all edge misses converge on one intermediate cache that sends a single fetch upstream.
| Layer | Requests merged | Remaining origin traffic |
|---|---|---|
| Single edge server | Clients of that server | One fetch per server |
| Point of presence | Clients across servers in one location | One fetch per location |
| Origin shield | Misses from all edge locations | One fetch per shield region |
| Origin reverse proxy | Requests reaching the origin cluster | One fetch to the application |
Major platforms such as Fastly, Akamai, Cloudflare and Amazon CloudFront implement collapsing natively, and open-source proxies offer it as configuration: Varnish collapses by default, while NGINX uses the proxy_cache_lock directive. The defaults and timeouts differ, so operators should verify the behavior rather than assume it.
Request collapsing compared with related caching techniques
Request collapsing protects the origin during a miss, while related techniques avoid or soften the miss itself. In practice, mature content delivery configurations combine them.
| Technique | Problem addressed | How it differs |
|---|---|---|
| Request collapsing | Duplicate concurrent origin fetches | Merges requests during a miss |
| Stale-while-revalidate | Latency at expiry | Serves the old copy while refreshing in the background |
| Stale-if-error | Origin failures | Serves the old copy when the origin returns errors |
| Origin shield | Many edge locations fetching separately | Adds a central cache tier |
| Cache prewarming | Cold cache after deployment | Fetches objects before users request them |
The combination of collapsing with stale-while-revalidate is particularly effective: users receive an immediate stale response, and only one background revalidation reaches the origin.
Limits, risks and configuration pitfalls
Collapsing introduces a dependency between unrelated clients, because every waiting request shares the fate of the leading fetch. If the origin is slow, all queued clients wait; if it fails, all may receive the error. Proxies therefore apply a lock timeout, often a few seconds, after which waiting requests proceed independently.
The most serious risk involves uncacheable or personalized responses. If the node waits for a response that turns out to be private, queued requests cannot reuse it and must be sent to the origin one by one, a pattern known as request serialization. Varnish addresses this with a hit-for-miss or hit-for-pass marker that disables collapsing for that object for a defined period.
| Symptom | Cause | Remedy |
|---|---|---|
| Long tail latency on misses | Slow origin blocks all waiters | Set a lock timeout and use stale content |
| Requests processed one at a time | Uncacheable response serializes the queue | Mark the object as pass for a short period |
| User sees another user’s data | Cache key omits a personalizing attribute | Exclude private content or fix the cache key |
| Origin overloaded after purge | Collapsing absent on some tier | Enable it at the shield and the edge |
Never enable collapsing for responses that depend on cookies or authorization unless the cache key reflects those values, because sharing a response between users then becomes a data leak.
The idea in brief
Imagine a crowd at a library desk. Everyone asks for the same new book, and it is not on the shelf yet. The librarian does not send a separate person to the warehouse for each request. Instead, one runner goes, and everyone in line gets a copy when the book arrives.
Request collapsing does the same for websites. Many people may ask for the same file at the same moment. The delivery network then makes a single trip to the original server and shares the answer. This keeps that server from being overwhelmed.
A practical scenario
A news publisher posts a breaking story and sends a push notification to two million app users. Within ten seconds, roughly 40,000 requests for the same article page and its main image hit the CDN, while the objects are not cached yet. Without collapsing, each edge server would forward its own misses, and the content management system behind the origin can handle only a few hundred requests per second.
Because the CDN collapses requests at each edge node and again at an origin shield, the origin receives only a handful of fetches for each object. The article becomes cacheable after the first response, and later updates use stale-while-revalidate. The site stays responsive throughout the traffic spike, and the origin servers remain at moderate load.