How long is the front-end cached data usually cached?

A mall has a cache on its system interface, but it is impossible for app to reload data every time it changes pages.

such as Banner diagram article list,

the current practice is to add storage time to Banner data in nedb or localstorage ;

determine whether there is Banner data in the local cache before each switching request if the current time - storage time if this time is greater than 2 hours , reload the new data from the interface and then write it to the local cache , otherwise the data will be used directly.
this efficiency is much faster than refetching from the interface cache, but is it feasible? Or is there a better way? Hope that God will not hesitate to give advice!

Jun.02,2021

first: do you need to update the merchandise of the mall in real time? There is no problem with real-time requests if necessary.
second: if you just want to switch pages without updating data, you can use keepalive to make requests that some pages that need to be cached are not in the interface when switching.
third: if you do what you think above, you can do it at a specific time to meet the needs of the product. However, this is not recommended. You can put something in the cache, but you don't want to put everything in the cache, especially for this kind of data


for most applications, the easiest way is to keep it in memory without localstorage, throw it away the next time you refresh the page, and reload it from the background, but for important data, you can refresh the user, such as articles, by giving a drop-down refresh. It doesn't matter if it's not important. The words of a family are for reference.


interfaces do not need to be cached at all. Shouldn't slow interfaces optimize interfaces? The caching of the front end is not optimized to the point.


localstorage is permanent storage, that is, as long as you do not call the localstorage.clear () method, or as long as the user uses the browser's cleanup feature, the data will always be there. Of course, localstorage is domain name isolated, that is, the methods under other domain names cannot view your localstorage data. So if you don't want to call the interface data multiple times, you can store it in localstorage. If you want the user to close the page and empty the data, consider sessionstorage.


in fact, the most important thing is to see whether this business data needs to be updated in a timely manner

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3dee4-4f038.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3dee4-4f038.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?