Maximum item size in IndexedDB

JavascriptHtmlIndexeddb

Javascript Problem Overview


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?

Javascript Solutions


Solution 1 - Javascript

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):

> By default in Firefox 4, a site can use up to 50MB of IndexedDB storage. If it tries to use more than 50MB, Firefox will ask the user for permission: http://mxr.mozilla.org/mozilla-central/source/modules/libpref/src/init/all.js#101 > > In Firefox for mobile devices (Google Android and Nokia Maemo), Firefox will ask for permission if a site tries to use more than 5MB: http://mxr.mozilla.org/mozilla-central/source/mobile/app/mobile.js#571 > [...] > > If the user grants permission for a site to exceed the 50 MB IndexedDB quota, then as far as I know Firefox does not impose any more limits. The only limits on the size of the IndexedDB database will be the user's disk space and operating system. > > The localStorage quota is 5000KB, and there is no way for a web site to ask the browser for permission to store more than that amount in localStorage.

Solution 2 - Javascript

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.
  • Internet Explorer 10 : By default , user is prompted for storage at 10 MB. 250 MB per domain is the hard limit by default, however user can configure their own limits till 1 GB.

Solution 3 - Javascript

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-

const quota = await navigator.storage.estimate();
const totalSpace = quota.quota;
const usedSpace = quota.usage;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionacanimalView Question on Stackoverflow
Solution 1 - JavascriptNickolayView Answer on Stackoverflow
Solution 2 - JavascriptGemKView Answer on Stackoverflow
Solution 3 - JavascriptMadhur BansalView Answer on Stackoverflow