Replies: 1 comment
-
I'm mostly interested in justifying a PR to set Thinking of other use cases for this library, I suppose a Perhaps it also works as some global backend cache... but the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using React Query with Next.JS, very similar to the provided example: https://react-query.tanstack.com/guides/ssr (prefetch + hydrate)
I also have a test script that boots up my NextJS server, pings it with a few requests, then shuts down. I ran into an issue that the test process never exited, and eventually landed on the issue being similar to Jest.
My understanding is that the cache is used to dedupe requests and provide a source-of-truth for a given queryKey. Given that SSR lifecycle for a given QueryClient should only be a single request
the cache should be "permanent" for the lifecycle of the request (realistically a few milliseconds) and then cleaned up (probably through NodeJS's default garbage collection)
So the obvious solution to me is to just set
cacheTime=Infinity
for all server-side QueryClients. (All the time, regardless of test/production environment/framework)So to get to my question, is there ever a reason for cacheTime to not be Infinity during SSR? Are there any supported use case server-side query clients over a long period of time, or multiple sessions/requests?
It seems like a benefit to set Infinity (by default) server-side for
cacheTime
?Beta Was this translation helpful? Give feedback.
All reactions