简体   繁体   中英

Best practice to store data locally for web

I'm working on some web application and we need to store number of javascript objects in local storage. Until now we did it using cookies but we want to use one of HTML5 storage solutions because cookies data is send to server on each server call and it is a waste of resources and also it's size is very limited. The data should be stored permanently, I mean it should be available after closing the browser and opening it again.

What is the best practice to do this? Is there any way to store objects in local storage. Thanks for the assistance

In my current project I'm using PouchDB library ( http://pouchdb.com/ ). It is a lightweight javascript database which can store data locally in browser (string, int, object etc). All stored data are still available after browser restart.

You should use it with some JS framework, in my case it is AngularJS (very simple integration).

Have a look at this link: http://slides.html5rocks.com/#web-storage

It sounds like HTML5's Local Storage is definitely a great option for you. That presentation has a lot of great info in that should help you decide on the best form of storage.

is a good option for storing javascript objects. 是存储javascript对象的好选择。

I strongly recommend you to read this -> https://developer.mozilla.org/en-US/docs/IndexedDB

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM