Answer the question
In order to leave comments, you need to log in
What is the best way to cache received data from the server?
Hello!
Introductory:
We have a web admin panel for the *XX* service. It has settings for:
- users
- products
- store addresses
- customer tags
- product types
- etc.
For example , tags and product types are edited extremely rarely, but are requested frequently. We want to cache them somewhere in the localstore and check every time the page is updated to see if updatetAt has changed. If they have not changed, then we get it from the localstory
Question:
How to properly perform caching of this kind?
Answer the question
In order to leave comments, you need to log in
The server should cache, and the front should request, albeit the same thing.
Either request 1, and then simply check if there is no data in the variable, request.
localstorage is not a 1TB hard drive for you. There can be a meager amount of data and it’s stupid to keep a certain database there, besides, it’s more cumbersome to make changes there if you need to change 1 element.
In addition, if the data on the server has changed, how should the front understand this? In my opinion, a stupid decision that will not lead to anything good.
localStorage is limited to five megabytes, so it can break all of a sudden. For your situation, I advise you to consider IndexedDB .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question