Completely disable cache between two pages.
I just found this thread: https://discord.com/channels/719702312431386674/1003327027849474198/1064541918186442763
So looks like since v4, the behaviour is do not refetch even we set
gcTime
(cacheTime
before v5) to 0
.
But I want to disable a cache completely, When components mount and unmount, the query should refetch. I also set staleTime
to 0
but it's sitll no working. Any suggestions?
Btw. the AI on the doc website still gives deprecated cacheTime
property. (pic)
2 Replies
eastern-cyan•12mo ago
as specified in the thread you found, this is the expected behavior, if you use a query in multiple places it subscribes to the same data, if you already fetched some data why not reuse it?
If you want to refetch everytime, do a manual .refetch() on page focus.
vicious-gold•12mo ago
with
staleTime: 0
you should see a refetch when a new subscriber mounts, unless you have changed the refetchOnMount
setting. Please show a reproduction