how does deduping works in tanstack router
Hi. I wonder how does deduping works in tanstack router and is there any samples I can see?
4 Replies
foreign-sapphire•2y ago
deduping of what?
magic-beigeOP•2y ago
Same HTTP GET requests.
I would like to do a demo where the same 2nd http get request will be ignore if the first get request is still in in-flight.
foreign-sapphire•2y ago
is this related to loaders?
or which kind of requests
magic-beigeOP•2y ago
Ah yeah. Data loading. Docs says "Handles deduping, preloading, loading, stale-while-revalidate, background refetching on a per-route basis".
I got it now. It has to have loader deps.
"Using these dependencies as keys, TanStack Router will cache the data returned from a route's loader function and use it to fulfill subsequent requests for the same route match. This means that if a route's data is already in the cache, it will be returned immediately, then potentially be refetched in the background depending on the "freshness" of the data."
I just don't have an idea how to reproduce this in my demo app.