Skip to content
\n

And then, in our app.tsx, we're using these options:

\n
const queryClient = new QueryClient({\n  defaultOptions: {\n    queries: {\n      gcTime: 1000 * 60 * 60 * 24, // 24 hours\n    },\n  },\n});\n\n...\n\n    return (\n      <PersistQueryClientProvider\n        client={queryClient}\n        persistOptions={{\n          buster: apiPackage.version,\n          persister: createIDBPersister(),\n          maxAge: 1000 * 60 * 60 * 24,\n        }}\n        onSuccess={() => console.log(\"Mounted persist query client provider!\")}\n      >\n        ... app code ...\n      </PersistQueryClientProvider>\n    );\n
\n

What I can't figure out is this: Why is the set() method getting called so much? It's getting called even before the first trpc responses come through. It's getting called maybe 25 times per navigation. For reference, here's the browser's console:

\n

\"image\"

\n

I notice the client is passed into the set method. Wouldn't that basically serialize all of the data in the app every time it gets called?
\nIs there a way to basically set only the new query responses, and not just all query responses?

","upvoteCount":2,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"
\n

Wouldn't that basically serialize all of the data in the app every time it gets called?

\n
\n

yes, because we store it in one storage entry. for fine grained persistence, please checkout the createPerister api: https://tanstack.com/query/v5/docs/framework/react/plugins/createPersister

\n

there are tradeoffs in both approaches

","upvoteCount":2,"url":"https://github.com/TanStack/query/discussions/6794#discussioncomment-8308173"}}}

PersistQueryClientProvider performance question #6794

Answered by TkDodo
joshbtay asked this question in Q&A
Discussion options

You must be logged in to vote

Wouldn't that basically serialize all of the data in the app every time it gets called?

yes, because we store it in one storage entry. for fine grained persistence, please checkout the createPerister api: https://tanstack.com/query/v5/docs/framework/react/plugins/createPersister

there are tradeoffs in both approaches

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@TkDodo
Comment options

@joshbtay
Comment options

@TkDodo
Comment options

@TkDodo
Comment options

Answer selected by joshbtay
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants