Can I check how much space my indexedDB is taking up?

Viewed 6800

I'd like to get a breakdown of how much storage space a web app I'm working on is taking up. More specifically I'm interested in the size of data stored in indexedDB.

I know I can use navigator.storage.estimate() to get a total value, but it shows over 1 mbyte even with an empty db, and I'm interested in knowing the size of indexedDB specifically.

Is there a way to check the size?

2 Answers

There is not currently a standard (or even non-standard) API that gives a breakdown of storage usage by type.

  • In Chrome's DevTools, the Application tab provides a breakdown of storage by type; click the "Clear storage" view in the top left and a graph should appear. This is useful for local debugging, but not understanding storage usage "in the wild"

  • There's some discussion about extending navigator.storage.estimate() with this data at https://github.com/whatwg/storage/issues/63

UPDATE: navigator.storage.estimate() now provides a breakdown (in Chrome 75 and later) by storage type.

Yes you can make use of the Quota Management API to get these information. this is an experimental feature and currently not supported by EDGE

This site will give you information how Browser support this and can see in real

Example

// Query current usage and availability in Temporary storage:
navigator.storageQuota.queryInfo("temporary").then(
  function(storageInfo) {
    // Continue to initialize local cache using the obtained
    // usage and remaining space (quota - usage) information.
    initializeCache(storageInfo.usage,
                    storageInfo.quota - storageInfo.usage);
  });

More reading is available in W3org

Related