What can you use the HTML5 storage feature for?
Not sure if I understand HTML5 storage correctly.
Is it just kind of a an advanced cookie store where user data can be persisted without a particular schema - like a key/value store?
If so, what types of features could it be used for?
I'm having a hard time imagining how it could 开发者_JAVA技巧be applied in a web app that already has its own server-side persistence mechanism - not to mention the complexity of performing sync between client storage and server-side storage.
Yes, its a key/value store.
It could be used for all kinds of things where the data doesn't need to be stored on the server. You're only limited to the ideas you can come up with.
One example I've seen is a notetaking app that stores all of your notes on your own computer. Nothing touches the server. (I think it was more a proof-of-concept. Realistically, I think the notes ought to be saved server-side and client-side, and kept in sync.)
- it adds better control over what is transferred over the wire - cookies are always transferred to the server on each request, the app can choose what data is transferred from the HTML5 storage, when it needs it.
- it adds support for larger amounts of data - cookies are limited in size.
- it adds support for caching scenarios - an example is a web app that deals with huge blobs of data - it is better to download the data once to the local storage and subsequently download only incremental updates.
- it adds support for offline scenarios - an example is a web app that allows you to work with your data even without persistent connection to their servers and uploads when it detects connection.
Wouldn't it be great if you didn't have to send everything server-side every time you changed something? What if you were going to be disconnected from the net for a bit but still wanted to carry on? Just because you're used to persisting data server-side, doesn't mean it wouldn't be better to persist it (temporarily at least) client-side.
精彩评论