Client Query Invalidation does not invalidate server side caches #4271
Replies: 2 comments 9 replies
-
I don't really know what nextJs does with variables created on the server, outside of The docs state that you should:
So I would say support for what you're trying to do is at best undocumented. There is also a discussion here where the idea was to create the client inside getServerSideProps, and then persist it to redis with the persister plugins: |
Beta Was this translation helpful? Give feedback.
-
@TkDodo Thanks for ur input Dominik. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
When creating a queryClient outside my getServerSideProps (next.js) I am able to cache queries on the server, giving visitors of the app the ability to request a cached api fetch which is not made for every client again and again.
This works- however when trying to invalidate the cache via
queryClient.invalidateQueries()
withinSo how do I invalidate cached queries made by node.js then? Can this be done server side or client side?
Is there a useQueryClient variant for non react components?
I am not sure if this is a bug or was never planned to be working.
Your minimal, reproducible example
not created so far as 1st needs clarification
Steps to reproduce
Expected behavior
Caches get invalidated
How often does this bug happen?
No response
Screenshots or Videos
No response
Platform
osx 12.1
"react-query": "^3.39.2",
"react": "^18.2.0",
"next": "^12.1.4",
react-query version
3.39.2
TypeScript version
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions