I have a JSON Data to store in local storage which is being used by a lot of components in my application. In some cases, the data exceeds 100 Mb and my browser throws an error, "localStorage.setItem exceeded the quota". But it is very important for me to cache this data as downloading with slow down my application. Could some suggest me a simple and effective way of achieving this?
Asked
Active
Viewed 620 times
1
-
Are you sure that `localStorage` allows you to store data up to 100MB? – Keyur Ramoliya Nov 19 '18 at 09:51
-
I'd use IndexedDB instead. – CertainPerformance Nov 19 '18 at 09:53
-
@CertainPerformance does it work for all the browsers. I am focussing on at least Chrome, FF & Edge. – khushboo j Nov 19 '18 at 10:14
-
Yes, IndexedDB is widely supported – CertainPerformance Nov 19 '18 at 10:14
1 Answers
1
Try having the data compressed. This might help depending on your JSON data. https://coderwall.com/p/mekopw/jsonc-compress-your-json-data-up-to-80 This api says it compresses up to 80% of data in a JSON string.
I believe this is the JS file from it https://github.com/tcorral/JSONC/blob/master/src/JSONC.js