我可以检查indexedDB占用多少空间吗?

时间:2018-11-01 19:07:15

标签: browser storage indexeddb

我想了解我正在使用的Web应用占用了多少存储空间。更具体地说,我对存储在indexedDB中的数据大小感兴趣。

我知道我可以使用navigator.storage.estimate()来获得一个总值,但是即使有一个空的db,它也显示了超过1 MB的字节,并且我有兴趣专门了解indexedDB的大小。

有没有办法检查尺寸?

2 个答案:

答案 0 :(得分:2)

当前没有标准(甚至是非标准)API可以按类型细分存储使用情况。

  • 在Chrome的DevTools中,“应用程序”标签按类型提供了存储的细分;点击左上方的“清除存储空间”视图,然后会出现一个图形。这对本地调试很有用,但不能“自然”地了解存储使用情况

  • 有人在https://github.com/whatwg/storage/issues/63

  • 讨论了如何使用此数据扩展navigator.storage.estimate()

答案 1 :(得分:-1)

是的,您可以使用配额管理API 来获取这些信息。这是一项实验性功能,EDGE目前不支持

This 网站将为您提供信息,该信息表示浏览器如何支持此功能并可以实时查看

示例

// 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);
  });

W3org

中提供了更多阅读内容
相关问题