0

I'm building a NextJS application for a small company. This application consists of a dashboard used by the 10 employees of this company and functions as an ERP.

We have an API that provides information for all entities, and the React components consume the endpoints of this API. I'm thinking of using RTK Query and its cache functionalities to reduce the number of API calls.

I know that RTK Query has strategies for Refreshing Cached Data (tags, etc). However, the problem is that with 10 users using this web application simultaneously, there's a risk that one client updates a resource (creates a new entity or updates an existing one) and the other 9 users see outdated data.

How to solve this?

3

1 Answer 1

1

If you are planning on using rtk-query on the client side to fetch from your api, it's not something that any 'caching fetched data - storage' will be able to help you with. Since the client will never know of state (db etc.) changes made by others in the api. Some kindof polling/web socket connection could help with that though.

If you are going to run your redux store on your next server, you should be able to invalidate your cache (tags) on mutations made by anyone and hydrate the updated state to the client somehow. Not sure how that is done in nextjs, but should be possible

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.