Request Deduplication
When multiple components request the same resource at the same moment, WELD detects the duplicate and binds all callers to a single in-flight Promise instead of firing N requests to the server.
The problem it solves
Section titled “The problem it solves”Imagine a dashboard with 3 components that all need the current user’s data on mount:
// Component Aconst user = await api.get('v1/me').promise
// Component B (mounts at the same time)const user = await api.get('v1/me').promise
// Component C (mounts at the same time)const user = await api.get('v1/me').promiseWithout deduplication: 3 network requests hit your server simultaneously.
With WELD: 1 network request, all three components get the same result.
How it works
Section titled “How it works”WELD generates a deterministic cache key from the request method, URL, query params, and body. If a request with that key is already in flight, the new caller gets the existing Promise back instead of starting a new one.
Request A → key: "GET::/v1/me::::" → no match → starts fetch, registers PromiseRequest B → key: "GET::/v1/me::::" → match found → returns existing PromiseRequest C → key: "GET::/v1/me::::" → match found → returns existing Promise
Server receives: 1 requestAll 3 callers receive: same dataOnce the Promise settles (success or error), it’s removed from the map automatically.
Deduplication is on by default
Section titled “Deduplication is on by default”You don’t need to configure anything. It’s active for all GET requests automatically.
// These three calls — even from different components — share one requestapi.get('v1/products', Schema)api.get('v1/products', Schema)api.get('v1/products', Schema)Disabling it
Section titled “Disabling it”const { promise } = api.get('v1/products', Schema, { deduplicate: false, // always fires a new request})