Monday, February 9, 2015

Localstorage size limitations




We have started relying highly on localstorage and are storing lots of data in localstorage. However, it also has a limit beyond that it would not work and would request data from server directly for each request.

Defaults:
Default value of storage capacity can be viewed as below:

Firefox - 
1. In the URL type about:config
2. Search for dom.storage.default_quota in the config parameters. You will find value as 5120 which will translate to 5MB

Chrome  -
Limit is listed as 5MB on Chrome specs

IE - 
The limit is listed as 10MB on IE Specs


Current usage check
You can check current usage of localstorage by running following javascript in the browser console:
var total = 0;for(var x in localStorage) {  var amount = (localStorage[x].length * 2) / 1024 / 1024;  total += amount;  console.log( x + "=" + amount.toFixed(2) + " MB");}console.log( "Total: " + total.toFixed(2) + " MB");


Here is some javascript code to find the size of your localstorage http://jsfiddle.net/b31gzjys/2/
During my research I found this blog very helpful- Dom storage