A popular public page can receive several requests before its first response enters the cache. Request collapsing lets a cache combine eligible misses into one origin fetch. The useful result is less repeated work with correct responses and bounded waiting for every visitor.
Define the one-response group
Start with a single public GET route whose output is identical for the intended visitors. Write down the route, query parameters, relevant request headers and response policy. Record why these requests may share one response. A familiar URL alone is insufficient evidence: a cookie, language preference or authentication state may change what the application returns.
The HTTP caching specification on constructing responses permits a cache to combine requests when the resulting response is reusable for them. It also explains the important failure case: if the response cannot satisfy some waiting requests, those requests need forwarding and can incur additional latency. Treat reuse eligibility as the first test, ahead of throughput.
Keep this experiment separate from a general cache configuration exercise. The question is what happens during the interval between the first miss and a reusable response becoming available. A warm-cache benchmark largely skips that interval. The existing CDN and edge caching guide provides the broader policy context; here, concentrate on the requests that arrive together.
Draw the queue before changing it
Describe the actual path in plain language: browser, edge cache, regional cache, reverse proxy and application. Remove layers that your service does not use. For each remaining layer, identify whether collapsing exists, its scope and how to observe waiting. Do not assume that a feature at one node coordinates every cache node in a region.
Name the first fetch the leader and the requests sharing its result the waiters in your test notes. These are analysis labels, not required HTTP fields. Record what happens when the leader succeeds, times out, is cancelled or returns an ineligible response. A setting called cache lock may cover only part of that behavior.
Ask which component owns the waiting deadline. A client may give up before a proxy does, while the origin continues working. List client, proxy and application deadlines in their actual order. The goal is to understand who can still hold resources after the visitor has left, not to make every timeout numerically identical.
Build a small cold-cache experiment
Use a staging route with a fixed, recognizable response and a controllable origin delay. Choose a modest request count that your test system can handle. The delay is an experimental condition, not a claim about production speed. It creates enough overlap to see whether concurrent misses join the same fetch.
Clear only the chosen test object using the supported invalidation mechanism. Confirm the relevant cache layer is cold, then release the requests close together. Use the same URL and equivalent headers for the first group. Adding a random query string to every request usually creates different candidates and defeats the question you wanted to test.
Run a warm control after the object is populated. Then repeat the cold run with collapsing disabled, if your system provides a safe switch. Keep response size, delay, concurrency, client location and cache node consistent. Record configuration changes alongside results so a later reviewer can reproduce the comparison.
| Test condition | Evidence to collect | Decision it supports |
|---|---|---|
| Cold, equivalent requests | Origin fetch count and waiter duration | Whether duplicate work is combined |
| Warm, equivalent requests | Cache reuse and response identity | Whether ordinary reuse still works |
| Cold, different variants | Body identity for each group | Whether requests remain correctly separated |
| Slow or failed leader | Deadlines, errors and new fetches | Whether recovery bounds the queue |
Count origin work and visitor waiting together
Give every client request an identifier in the test harness. Where available, connect it to the cache transaction and origin request in logs. Avoid putting unique experimental headers into the cache key accidentally. Check the key definition before concluding that collapsing is broken because every request produced its own origin fetch.
Count origin requests for the chosen object within the test interval. Also measure each visitor's time to first byte, total response time and result status. A smaller origin count is useful evidence, but it cannot show whether visitors waited too long or received an error. Keep the distribution, including the slowest requests, rather than reporting only an average.
Compare response bodies using an expected value or digest. Record relevant response headers separately, because request identifiers and timing fields can legitimately differ. If the response contains an unpredictable timestamp or token, redesign the fixture so correctness is testable. Do not normalize away user-specific content just to make the digests match.
For a multi-node test, group observations by cache node or another reliable routing identifier. Several origin fetches may represent separate groups that never shared a coordination scope. Investigate that boundary before treating a count greater than one as a defect. The acceptance criterion should describe the deployed topology, not an imagined global lock.
Make mismatches explicit
Next, introduce one difference at a time. Use two languages, two meaningful query values or another real representation choice supported by the route. Check that each request receives its intended content. A successful reduction in origin work is a failure if the cache joins groups whose responses are not interchangeable.
Test the path that returns a private or otherwise nonreusable response. Observe whether waiters are released, forwarded independently or failed, according to the implementation. Measure the added wait before that decision. This case is especially useful when a route is usually public but can switch behavior after an application change.
Keep authenticated and personalized traffic outside the first rollout. If later work expands eligibility, require a separate review of request matching and response policy. Do not remove cookies, ignore authorization or broaden a cache key merely to improve the collapse ratio. That would change the correctness contract rather than improve its execution.
Put a limit on slow leaders
Repeat the experiment with a leader that exceeds the intended waiting budget. Then test a connection failure and an origin error. Observe whether a new leader starts, whether many waiters fetch independently and whether any completed response is stored. These outcomes differ across implementations and need direct measurement on the deployed version.
Choose a waiting budget from the route's service objective and measured origin behavior. A longer wait can reduce duplicate work while making one slow fetch affect more visitors. A shorter wait can release visitors sooner but produce another burst against an already struggling origin. Document that tradeoff with the observed request timeline.
Test cancellation separately. End a waiting client connection, then confirm that its queue entry and other resources are eventually released. Also cancel the original client that triggered the leader. Determine whether the cache continues the shared fetch for remaining waiters. Avoid assuming that client cancellation and upstream cancellation are the same event.
Repeat across expiry and deployment
A manual purge is only one way to create simultaneous misses. Repeat the test after normal expiry, after a targeted invalidation and after a deployment that changes response content. Check that the new response reaches all eligible waiters and that an older in-flight operation cannot unexpectedly repopulate the object with an obsolete version.
Use an explicit content version in the fixture to distinguish old and new output. Preserve a timeline of invalidation, leader start, origin completion and cache insertion. If the implementation does not expose insertion time, record that limit instead of inventing an exact order from client observations alone.
Test the actual rollout procedure, including any prewarming step. Prewarming can reduce cold requests, but it does not prove the queue behaves safely when an unanticipated object becomes popular. Keep one deliberately cold route in the controlled test so a successful warm run cannot hide the failure mode.
Release with a reversible route policy
Start with a small, explicitly public route set. Keep a direct way to disable collapsing for that set while preserving the underlying cache rules. Watch origin request count, application saturation, waiter duration, response correctness and errors together. Establish rollback conditions before the change, with ownership assigned to someone who can act.
Compare equivalent traffic periods and cache states. A quiet interval after a warm-up is not evidence that collapsing solved a previous traffic spike. Keep the cold-burst fixture as a repeatable check and rerun it after proxy upgrades, routing changes or modifications to personalization. Those changes can alter the group boundary without changing the visible URL.
Accept the change when the evidence shows fewer redundant fetches for the intended group, correct content for every tested variant and a bounded recovery path for slow or failed leaders. Keep the measurements and configuration with the release record. Request collapsing earns its place by protecting origin capacity without turning one delayed response into an uncontrolled queue.