IndexedDB 中的最大项目大小
我正在开发一个简单的 Web 实用程序,它利用 HTML5 的 IndexedDB(类似于键值数据库)功能。
我一直在寻找,但无法知道:我可以在物品中存储的最大尺寸是多少?
I'm working on a simple web utility that makes use of IndexedDB (similar to a key-value DB) feature of HTML5.
I was looking for but I was unable to know: what is the maximum size I can store in an item?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为单个项目的大小没有具体限制,只有全局限制。
自最初编写此答案以来,有关全局限制的规则已发生变化。 最新文档位于 MDN - 根据可用磁盘空间,“组”限制(对于给定域,包括其所有子域)范围可以为 10 MB到 2 GB。
旧的答案 - 随着 Firefox 38 (2015-05) 的发布而废弃,删除了
dom.indexedDB.warningQuota
:来自 mbrubeck at support.mozilla.com(我已经替换了他的链接)随 perma 版本提供):
I don't think there's a specific limit for a size of a single item, only a global limit.
The rules regarding the global limit have changed since this answer was originally written. The up-to-date docs are on MDN - depending on the available disk space, the "group" limit (for the given domain, including all of its subdomains) can range from 10 MB to 2 GB.
The older answer - obsoleted with the release of Firefox 38 (2015-05), which removed
dom.indexedDB.warningQuota
:From an answer by mbrubeck at support.mozilla.com (I've replaced the links he provided with perma-versions):
对于使用现代浏览器的普通网站,您无需担心 indexedDB 中的可用存储空间,因为它要高得多。
最大存储大小取决于两个因素:浏览器和磁盘空间。
因此,Chrome 和大多数基于 chromium 的浏览器允许使用 80% 的磁盘空间,其中每个源可以使用 75% 的磁盘空间。这意味着,
如果您有 100GB 的磁盘空间,则 80GB 可用于在 indexedDB 中存储数据,其中 60GB 可供单源使用。
此外,Firefox 允许每个源存储 2GB 数据,Safari 允许每个源存储 1GB 数据。
您可以通过以下方式检查可用空间和已用空间的总空间:
For a normal website using modern browsers, you don't need to worry about the available storage in indexedDB as it is way higher.
Maximum storage size depends on 2 things, Browser and Disk space.
So, Chrome and most of the chromium-based browsers allows 80% of the disk space to be used and from that 75% can be used by each origin. That means,
If you have a disk space of 100GB then 80GB can be used to store data in indexedDB and from that 60GB can be used by single origin.
Also, Firefox allows 2GB data to be stored by each origin and Safari allows 1GB per origin.
You can check the total space available and used space by-
添加到 Nickolay 答案,以下是 Chrome 和 IE
Chrome(Desktop) 中 IndexedDB 容量的描述
Android 版 Chrome:找不到任何说明配额的官方链接。但根据我的经验,我在没有任何提示的情况下保存了 300 MB 的数据。行为很可能与桌面 Chrome 相同。
Adding to Nickolay answers, Here is the description of IndexedDB capacity in Chrome and IE
Chrome(Desktop) : By default, For Web-apps chrome doesn't prompt the user while storing data using indexedDB API. It uses the concept of shared pool, here is the complete description - Chrome HTML5 Offline Storage
Chrome for Android : Couldn't find any official link for stating quota. But from my experience, i have saved 300 MB of data without any prompts. Most probably same behavior as Desktop Chrome.