Disable loaderData cache
Is it possible to disable the cache for the loaderData completely for a route?
4 Replies
wee-brown•2y ago
Does it cache by default? I'm pretty sure it doesn't. The staleTime is 0 by default. I'm fairly new to the cache tweaking. I'm just starting off looking into it today.
relaxed-coral•2y ago
https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#%EF%B8%8F-some-important-defaults
By default the
staleTime is set to 0, but a previously loaded route is considered "fresh" for 30 seconds (gcTime).Data Loading | TanStack Router React Docs
Data loading is a common concern for web applications and is related to routing. When loading a page for your app, it's ideal if all of the page's async requirements are fetched and fulfilled as early as possible, in parallel. The router is the best place to coordinate these async dependencies as it's usually the only place in your app that kno...
flat-fuchsia•9mo ago
setting
defaultGcTime: 0 when initializing the router disables caching.
i was running into problems using loaderdata to set defaultvalues in my form. router would give me the old data when editing the same record again.relaxed-coral•9mo ago
I'd use the
staleTime flag instead.