Thom Smith
Thom Smith

Reputation: 14086

Storing a large amount of data in the browser

I'm working on a web application for searching, filtering, and exploring a fixed data set. The data set fits in about 10 MB of JSON. It will change a few times a year, and it can be updated incrementally.

I would like to store this data in the browser to avoid latency. This is a hard requirement -- the profound gain in responsiveness is the entire reason to create this application when many excellent alternatives exist. I accept that it won't work well for some users.

What is the best way to store this data persistently in the browser? I could pack it into localStorage, but I'd have to decompress and JSON.parse it on every page load. I've heard good things about IndexedDB, but I'm not sure that it's well-suited to storing a single giant blob.

Upvotes: 5

Views: 4606

Answers (1)

Uzer
Uzer

Reputation: 3190

If your data is smaller than 10MB then you could store it in localStorage however the size of the storage can customised by the user so this seems on the limit. Also you would be stuck doing parse/stringify frequently, and only able to filter in-memory.

Using indexedDB is probably your best option as it can storage more. There is apparently no limit to the size of a single item, so you could do one giant value blob if you wanted to.

Can you describe the structure of the data further? If its a list then your data is partitionable. You could leverage indexes to enable searching for exact list item values quite efficiently.

Upvotes: 1

Related Questions