Local storage localstorage & sessionstorage compatibility, API, features

Source: Internet
Author: User
Tags http request time limit sessionstorage

Since the discovery of cookie storage in the development is in the HTTP request header, it greatly affects the data request interaction.
So to learn the H5 of several storage optimization methods, hereby note.

Storage mode:
1. Local storage localstorage & Sessionstorage;
2. Offline storage application cache;
3. Browser database IndexedDB;

Study and use judgment:
This is a browser-compatible search site: http://caniuse.com/
Figure one: Localstorage & sessionstorage Compatibility

No more stickers below
Application cache compatibility is 90.44%
IndexedDB compatibility is 79%

Because I work for the reason, so detailed records Localstorage & sessionstorage use

Timeliness:
Localstorage-* No time limit for data storage
Sessionstorage-Data storage for a session

Api:
Localstorage.getitem (' key ', ' Val ')-Get
Localstorage.setitem (' key ')-set
Localstorage.removeitem (' key ')-remove
Localstorage.key (0)-Take the key value
Localstorage.clear ()-Empty

Special-Picture storage:
1. Create a canvas
2.drawImage this picture
3.toDataURL convert the picture to Dataurl
4. stored in the Localstorage

Special-Compatibility:
1.ios non-mark browsing failure;
2. There is no way to have the Object Browser;

* This article belongs to the abstract from the video, thanks Friday

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.