Comparison of local storage methods

         There are many local storage methods, such as cookies, localstorage, sessionstorage, userData, Flash, and Globalstorage.
         The advantages of local storage are:
         1. Avoid a blank page before retrieving data. If the latest data is not needed, the number of requests to the server can also be reduced, thereby reducing the time for users to wait for data to be obtained from the server;
         2. The network status is not When the best time, offline data can still be displayed.
         Then compare the differences between different local storage methods:
          1. cookie, an option used by the client to store data, which can be set on the client side or on the server side. The cookie will be sent along with any HTTP request. All browsers support it and can control the life cycle, but there are size restrictions, it will also increase traffic, and it may be disabled by the client.
          2, localstorage, the size is expanded, most desktop browsers will set a limit of 5MB per source, Google and Safari limit each source is 2.5MB. The limit of Safari of iOS and webkit of Android is also 2.5MB, which is not affected by the window. The disadvantage is that it is stored locally for a long time after initialization and is not affected by the length of the session. If you want to delete it, you must manually clean it up.
          3. Sessionstorage, the size is expanded, the life cycle is a session cycle, that is, from opening to closing the browser window, of course, it must be an online user, it must be the same window, and the sessionstorage between different windows is different.
          4. userData has a controllable life cycle, and the storage capacity is expanded. The size of a single file is 128kb, and a domain name can store 1024kb files, but only in Windows+IE environment.
          5. Flash, the size has been expanded, and all browsers support it, but it needs to introduce .swf files and a lot of js in the places where it is used, which is rather cumbersome.
          6. Globalstorage, after the browser is closed, the information stored using Globalstorage can still be saved. Like sessionstorage, the information stored on any page in the same domain can be shared by all pages, but only FF is supported, and only current Globalstorage storage under the domain.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327019441&siteId=291194637