Layer 1: Subgraph Request Deduplication
Deduplicates identical fetches to the same subgraph across concurrent operations. The deduplication key is:- DataSourceID: identifies the target subgraph
- requestBody: the complete JSON payload (query + variables)
- preComputedHeaderHash: xxhash64 of all headers that will be forwarded to this subgraph, as determined by your header forwarding rules
Query operations are eligible. Mutations and subscriptions are never deduplicated.
Layer 2: Inbound Request Deduplication
Deduplicates identical client requests before the engine even starts resolving. The key is:privateIdDigest is only set when the response cache has a private_id. See With the response cache.
How Header Hashes Are Computed
The header hashes for both layers are computed bySubgraphHeadersBuilder, which:
- Iterates over every subgraph involved in the execution plan
- Applies all configured header forwarding rules (global + per-subgraph) against the current inbound request headers
- Produces a deterministic
uint64hash per subgraph - Combines all per-subgraph hashes into a single
allHash
RouterOnRequestHandler and RouterMiddlewareHandler hooks run, but before EnginePreOriginHandler.OnOriginRequest hooks run.
Request Pipeline and Hook Ordering
With the Response Cache
The response cache and both layers of deduplication work together:- Inbound deduplication runs before the cache. Only the leading client request looks up and writes cache entries. The others receive its client response.
- Client requests with different private ids never share a flight. The private id is part of the inbound key, so one user never receives another user’s cached private data.
- Subgraph deduplication runs after the cache lookup. Client requests that miss on the same fetch at the same time send the subgraph one call between them. Each of them then writes the same cache entries.
- Some client requests skip inbound deduplication. A client request with
Cache-Control: no-cache,max-age=0oronly-if-cachedresolves on its own, because it may need a different answer from the cache than the request it would join. Its subgraph fetches are still deduplicated.
Configuration Reference
ENGINE_ENABLE_SINGLE_FLIGHTENGINE_FORCE_ENABLE_SINGLE_FLIGHTENGINE_ENABLE_INBOUND_REQUEST_DEDUPLICATIONENGINE_FORCE_ENABLE_INBOUND_REQUEST_DEDUPLICATION