3

i'm working on caching objects as JSON and i saw that indexedDB is a great place to do it but i'm wondering that if it has a size limit


  • is there any limit for indexedDB?

  • if it has,how can make it unlimited?


i'm using vanilla javascript

thanks a lot

Jood jindy
  • 320
  • 4
  • 18
  • 1
    Does this answer your question? [Maximum item size in IndexedDB](https://stackoverflow.com/questions/5692820/maximum-item-size-in-indexeddb) – Mike Doe Mar 03 '20 at 20:59
  • i'll take a look at it thanks – Jood jindy Mar 03 '20 at 20:59
  • they didn't mention chrome – Jood jindy Mar 03 '20 at 21:06
  • The second answer mentioned Chrome and even linked to the documentation which explains Chrome uses a shared pool which consists of 1/3 (33%) of the disk space, and one origin can only use 20% of that, maximum. Chrome decides when you run out of space, and will throw an error. You're expected to handle that nicely on your end. – megubyte Mar 03 '20 at 21:12
  • wow i didn't see it..thamks for telling ,can you make your comment an answer so i can accept it? – Jood jindy Mar 03 '20 at 21:23

1 Answers1

1

As per the documentation, Chrome will reserve 1/3 of the disk for offline storage. This means if a disk is 99GB large, Chrome will reserve 33GB of storage for offline storage. I would imagine if the usable space is less than that that Chrome adjusts however much it claims to suit.

If an origin is not used often, in cases where the disk is running out of space, Chrome will delete an entire origins' offline storage. An origin can claim a maximum of 20% of the pool that Chrome has, meaning that on the aforementioned disk with 33GB of storage allocated to Chrome, you can only use 6.6GB of storage.

It's recommended though that you don't rely on having a lot of storage to play with. You should handle cases where Chrome denies you the ability to write offline storage, just like with any other app. Chrome will let you know when you attempt to write to offline storage, that you're out of storage.

megubyte
  • 1,549
  • 9
  • 15