skip to Main Content

In our project we need to give continuous updates, after updating the system, users need to clear their cache and localStorage data manually so that they can use the updates.

Is there any way to deal with the problem, where after updates all the cache will be cleared for once when the user comes to the site? the project is built upon Nextjs.

2

Answers


  1. you may use the function of the localstorage as:

    localstorage.removeItem(contents in localstorage to be removed);
    
    Login or Signup to reply.
  2. You need to have a setting which takes the version ID, compare it, if different then clear local storage and set the newer version on local storage, something like this code should work.

      var version = "v1.2";
      var storageversion = localStorage.getItem("version");
      if (storageversion !== version) {    
        localStorage.clear();
        localStorage.setItem("version", version);
      }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search