5

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

Boltosaurus
  • 2,138
  • 3
  • 21
  • 33

3 Answers3

4

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

apo
  • 116
  • 7
  • I created an [AngularJS wrapper for PouchDB](https://github.com/wspringer/angular-pouchdb), which makes it even easier. Just typing `
    {{contact.name}}
    ` will give you a list that is continuously taking the updates from the server and inserting it locally. AngularJS and PouchDB is awesome.
    – Wilfred Springer Mar 06 '14 at 10:54
2

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.

jskidd3
  • 4,609
  • 15
  • 63
  • 127
2

IndexedDb is a good option for storing javascript objects.

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

Özgür Kaplan
  • 2,106
  • 2
  • 15
  • 26