Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum item size in 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?

like image 806
acanimal Avatar asked Apr 17 '11 09:04

acanimal


People also ask

Can I store object in IndexedDB?

It lets you store just about anything in the user's browser. In addition to the usual search, get, and put actions, IndexedDB also supports transactions. Here is the definition of IndexedDB on MDN: IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs.

Is IndexedDB faster than LocalStorage?

In both Firefox and Chrome, IndexedDB is slower than LocalStorage for basic key-value insertions, and it still blocks the DOM. In Chrome, it's also slower than WebSQL, which does blocks the DOM, but not nearly as much.

Which is better LocalStorage or IndexedDB?

LocalStorage is slightly faster than IndexedDB in all browsers (disregarding the crashes). IndexedDB is not significantly slower when run in a web worker, and never blocks the DOM that way.

What can be stored in IndexedDB?

IndexedDB is a newer facility for storing large amounts of data in the browser. You can use it to store data of any JavaScript type, such as an object or array, without having to serialize it. All requests against the database are asynchronous, so you get a callback when the request is completed.


2 Answers

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.

like image 132
Nickolay Avatar answered Nov 04 '22 13:11

Nickolay


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.
like image 22
GemK Avatar answered Nov 04 '22 13:11

GemK