I’m using TanStack Query in my app to cache posts and post details on the client side.
When a user updates a post, I can call "queryClient.invalidateQueries()" to invalidate the cache for the current user
However, this only affects the current user’s browser/session.
What I want to understand is: how can I make sure that other users who are currently using the app also get the updated post data?
For example:
- User A updates a post.
- The server saves the update.
- User B, who already has the posts cached in their browser, should see the updated data too.
Does TanStack Query provide a way to invalidate cache across all users, or do I need to implement something like WebSocket/SSE to notify each client and then call "invalidateQueries()" locally?