Do all HTML5 storage systems work together?

Despite the fact that there is a lot of good stuff in html5, one thing I donโ€™t get is a backup storage mechanism, first there is localstorage and sessionstorage, which are key value stores, one for one application instance ("one tab"). and the other works for all instances of this application so that they can exchange data. Both are saved when you close your browser and have a limited size (usually 5 MB), which is great and everything will be fine if we stay there.

But then there is the "Web SQL Database", which has the same security system as localstorage, the same size as everything, except that it works like sqlite, with tables and sql syntax and all that.

And bummer, it doesnโ€™t work on the same data at all! These are not two ways to access your data, these are really two repositories for each html 5 application (not created by default, yes, but still you see my point).

What would I like to know if there is a reason why both of these mechanisms exist simultaneously? Or did they just look at the sql and nosql movement to select the best, and then go "twist it to add both!"? Why not implement local / session storage as a table inside web sql db?

+4
source share
2 answers

I believe that localstorage is the correct rewrite of how cookies should have been made in the first place. It has a very simple api and low barrier to adoption.

Web SQL is quite heavy, and it will be a serious pain to keep a simple value, so they have very different use cases. localstorage is actually implemented in WebKit using SQLite, but just does not display through WebSQL.

Session storage cannot be easily implemented inside the database because it is effectively in the global scope and you do not want the data to be visible to other tabs. Since this is temporary data, you generally will not want to store lots anyway, so you do not need transactions and queries.

See also: http://www.pubbs.net/200904/webkit/28373-webkit-dev-need-help-making-windowlocalstorage-span-processes.html

+5
source

I asked myself the same question, and here is the answer quoted from the Chromium wiki:

Q: Why is this happening on LocalStorage?

A: LocalStorage is inherently a parallelism disaster , depending on whether you want to implement the "storage mutexes" described in the specification. Chrome decided not to implement it. WebKit itself is a single thread / process (i.e. not parallelism)

Source: http://www.chromium.org/developers/design-documents/indexeddb

Web SQL can be useful if you want to copy the structure of your database locally for offline use.

But web SQL will not be implemented in firefox: http://us1.campaign-archive.com/?u=168bf22f976f5a68fe5770d19&id=6c2d73c957#standards

Mozilla, Microsoft and Oracle are working on an alternative to "IndexedDB": http://www.w3.org/TR/IndexedDB/

Work in progress in firefox: https://wiki.mozilla.org/Firefox/Projects/IndexedDB

Storage Demos:

0
source

Source: https://habr.com/ru/post/1307221/


All Articles