IndexedDB vs Storage

IndexedDB is often recommended for storing large amount of data in WebExtensions. "unlimitedStorage" seems to apply to both IDB and Storage (storage.local).

In case of non-tabular text data where the indexed searches are not needed, what is the benefit of using IndexedDB over Storage?

They both use object based architecture and there is a great performance overhead in case of IDB.

What do you mean by Storage? browser.storage.local?
If yes, then just be aware that it is stored in a single JSON file per extension, i.e. has to be read and written all at once. If that matches your access pattern, very well. If you have more than a few KB data in total and need to read or modify individual parts of it frequently, the performance degrades.

Also, indexedDB is aware of Blobs and could handle them appropriately. Say you retrieve a blob from the BD, create an object-URL from it and then assign that by to an Image, the browser would only need to actually load the file when finally rendering the image.
I don’t know if Firefox actually does that, but id certainly won’t work if you dump base64 strings in a JSON file.

1 Like

Yes… storage.local

In the case I have in mind, I would also need to read the entire data at once and cache it.

I found out that searching the data every time performs worse than reading all and caching it (CPU vs Memory usage).

Sadly, I haven’t found a feasible way to search the IDB for what I need or else, searching the IDB could workout better than caching it (searching URL against patterns similar to GM). At the moment, the entire DB has to be read and checked and not way to find and individual record.

I dont plan to store blobs or base64 and as mentioned data would only contain text.