h5 cache mechanism

   H5 cache, probably localstorage, sessionstorage, cookies and manifest.

 一、LocalStorage

        LocalStorage is a permanent local cache that is stored on the client's browser and will not expire unless it is actively deleted. LocalStorage uses key-value pairs for storage, and the storage method can only be strings. The storage content can use pictures, json, styles, scripts, etc.

        Basic usage of the API:

         1. localStorage.setItem() storage

         2. localStorage.getItem() to get data, use localStorage.valueOf() to get all the data

         3. localStorage.removeItem(key) delete data

         4. localStorage.clear() clears all data, and localStorage.length obtains the number of locally stored data

         5. localStorage.key(N) Get the key value of the Nth data

二、SessionSotrage

       SessionStorage is used to locally store data in a session. These data can only be accessed by pages in the same session and the session ends. After the window is closed, the data disappears. is a session-level storage.

       SessionStorage is similar to localStorage

 3. Cookies

       Cookies are very different from sessionStorage and localStorage.

        

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970376&siteId=291194637