DroidOS
DroidOS

Reputation: 8880

IndexedDB & localStorage Storage Limits

From what I can understand Chrome imposes a "soft" limit of 5Mb on the size of data stored in localStorage and IndexedDB. There are a number of things here that are not clear to me

Compression would come at the cost of loosing the benefits of being able seamlessly to store/fetch JSON in IndexedDB (though this can be made transparent to my app with little extra effort).

I'd much appreciate any guidelines with these issues.

Upvotes: 3

Views: 7819

Answers (2)

DroidOS
DroidOS

Reputation: 8880

I wrote up a fiddle to examine what happens when the soft storage limits are breached - and also to test the utility of compressing what gets stored. Here is the fiddle

Local Storage Test

I have used the compression routines here for the test. The actual compression is easily done

var compr = LZString.compress(uncompr);

Notes

  1. The test need some time to execute so be patient!
  2. To increase the size of the stored data just increase maxTimes
  3. Compression works - very well indeed. However, as the tests will demonstrate, it can only realistically be used when storing relatively small (order of a few kb at the most) strings. For longer strings the compression itself takes too long and is liable to make your app unresponsive. I suspect that it would be better to question the need to store excessively long strings than to compress them.
  4. I use this technique for storing locally displayed HTML documents in localStorage and to store a range of configuration data objects in an IndexedDB database.
  5. Compressing data stored in IndexedDB means you loose the seamless storage/retrieval of JS objects that it offers. However, this can be dealt with easily via a simple wrapper.

Upvotes: 1

GemK
GemK

Reputation: 862

Here are the listed answers of your doubts:

I haven't tried compression with locallStorage, so no idea about that.

Upvotes: 2

Related Questions