Original address: http://ask.dcloud.net.cn/article/166
html5+ offline Local Storage has the following options:
HTML5 Standard Scheme : Cookies, Localstorage, Sessionstorage, Websql, IndexedDB
html5plus Extension Solution : plus.storage, Plus.io
- Cookies
The minimum volume, you can set the expiration time.
- Localstorage
Suitable for key and value value pairs of storage, the amount of data generally not more than 5M. is a common lightweight data storage solution.
- Sessionstorage
It is also a key-value pair, which is characterized by the disappearance of the app, which is generally not used for persisted data preservation, but for global variables.
- Websql
is the best solution for mobile phone-side relational database, all kinds of mobile phones are supported. Only the standard is no longer updated. But currently the only commercially available solution for weight data storage on mobile phones.
- IndexedDB
Is the latest data storage specification in HTML5, but is not based on SQL, but on objects.
INDEXEDDB performance is higher, all asynchronous processing, learning difficulty is too large. The most important is that the current mobile phone-side support is not. Android4.4 above and more than iOS8 support INDEXEDDB, temporarily unable to commercial on the mobile side.
- Plus.storage
Plus.storage is also a key-value pair data store. It is the OS to the native app using the key value of the storage database to encapsulate a layer to JS use.
Plus.storage does not have a theoretical size limit.
Plus.storage is a cross-domain feature compared to localstorage. Cross-domain issues are involved when a stored data needs to be read and written both locally and from the server. At this time HTML5 Localstorage can not meet the demand, can only use Plus.storage.
Plus.storage operation is slower than localstorage by dozens of milliseconds, if not because of size limit or spanning, try to use Localstorage.
- Plus.io
Plus.io is a file read and write, although you can also read and write txt and other files to store data, but not as professional storage and websql convenient.
Plus.io is more used for local preservation of multimedia files such as pictures.
The offline use of the text list is generally 2 ways of doing it:
1) Picture download does not through the IMG src, but plus.dowload download, first download the picture, save the path, then the IMG src dynamic specified file path
- 2) The image is downloaded using img src, and then the IMG is stored as a picture file with canvas. Next time the network is not networked, the IMG SCR directly points to the local file
Go Dcloud App offline local storage solution