Best practice to store data locally for web

5.3k views Asked by At

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

3

There are 3 answers

0
jskidd3 On

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.

0
Özgür Kaplan On

IndexedDb is a good option for storing javascript objects.

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

1
apo On

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).