reactjs – what techniques do react websites use to update static data?
If I understand correctly your website is storing in the local storage of the client browser a cache with the data about menus, you want to be able to update this data either periodically or even better when the master data have been updated.
There is various options, IMO the best would be Server Sent Events.
Server Sent Events
To trigger an update of your cache data on all browsers of your customers, Server Sent Events could be a solution, the limitation is that the communication is only server >> client. See documentation here
Scheduled task in browser
As proposed in @Feder 240516 answer, Tanstack seems interesting for it’s periodical reload
Long polling & HTTP Cache
Your browser code could periodically call your API and if the data didn’t changed the API would answer with the HTTP code 304 “Not Modified”, which would stop the process here. Until data is updated on the server and then your API will serve the fresh data to the browser on the next periodical call See documentation here
Websockets
If you expects to add features to your website that will require bi-directional communication server <> client, then websockets could be of interest. See documentation here
Read more here: Source link
