2

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

  • What precisely is meant by "soft" in this context?
  • Does this mean localStorage:5Mb + IndexedDB:5Mb?
  • I have not hit the buffers yet but then I keep clearing out my browser stores as I develop my app. What happens when the limits are reached? An exception is thrown and needs to be caught?
  • Would there be much mileage in compressing data prior to storage? This seems to offer an excellent route if data compression is worth doing.

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.

DroidOS
  • 8,530
  • 16
  • 99
  • 171

2 Answers2

2

Here are the listed answers of your doubts:

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

Community
  • 1
  • 1
GemK
  • 852
  • 7
  • 14
1

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.
DroidOS
  • 8,530
  • 16
  • 99
  • 171