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