google / WebFundamentals

Former git repo for WebFundamentals on developers.google.com
Apache License 2.0
13.85k stars 2.57k forks source link

Working with Web Storage Quotas (Guide) #3466

Open addyosmani opened 8 years ago

addyosmani commented 8 years ago

Old article: http://www.html5rocks.com/en/tutorials/offline/quota-research/ (this was A+ at the time. we don't currently have anything more recent in /web)

Recent related one: https://developers.google.com/web/updates/2011/11/Quota-Management-API-Fast-Facts?hl=en

There's also more info on Chrome's Quota nuance over in: https://docs.google.com/presentation/d/11CJnf77N45qPFAhASwnfRNeEMJfR-E_x05v1Z6Rh5HA/edit

PouchDB quota stats from https://pouchdb.com/faq.html:

IDB: Though Firefox has no upper limit besides disk space, if your application wishes to store more than 50MB locally, Firefox will ask the user using a non-modal dialog to confirm that this is okay.

Chrome also uses IndexedDB, and it determines the amount of storage available on the user’s hard drive and uses that to calculate a limit.

Opera 15+ shares a codebase with Chromium/Blink, and behaves similarly.

Internet Exporer 10+ has a hard 250MB limit, and will prompt the user with a non-modal dialog at 10MB.

Mobile Safari on iOS has a hard 50MB limit, whereas desktop Safari has no limit. Both will prompt the user with a modal dialog if an application requests more than 5MB of data, at increments of 5MB, 10MB, 50MB, 100MB, etc. Some versions of Safari have a bug where they only let you request additional storage once, so you'll need to request the desired space up-front. PouchDB allows you to do this using the size option.

iOS Web Application, a page saved on the homescreen behaves different than apps in Mobile Safari (at least from iOS 9.3.2+). No specifics are published online by Apple, but WebSQL storage seems not limited to 50mb and there will not be any prompts when requesting data storage. Use in your html header and use Add to Home Screen in the share menu of Safari. Please note, IndexedDB is not available, so FruitDown won't work. It seems there is different behaviour for different models of iPad and iPhone. You can check your mileage using the storage abuser, which you can Add to Home Screen on your device. Caveat: when iOS is running low on storage space, the OS might decide to delete all data without any notice or warning to the end user. Be sure to use devices with plenty of spare space, or your users will lose unsynced data.

Android works the same as Chrome as of 4.4+ (IndexedDB), while older versions can store up to 200MB (WebSQL).

In PhoneGap/Cordova, you can have unlimited data on both iOS and Android by using the SQLite Plugin.

My recent post with some quota related bits: https://medium.com/dev-channel/offline-storage-for-progressive-web-apps-70d52695513c#.qi4hx1qwg

cc @drufball. Initially assigning to @agektmr as he's had an interest in storage Quota in the past and wrote the original guide linked to above.

agektmr commented 8 years ago

@addyosmani We need to test with the latest browsers using this tool http://demo.agektmr.com/storage/ . I wanted to work on ES6'fying this and add Cache API but haven't got time yet.

addyosmani commented 8 years ago

@agektmr Re-testing would be fantastic if we can find the time. We're aiming to have a team-wide /web hackathon next week in case you think you'd be able to help update this then.

agektmr commented 7 years ago

FYI, I'm testing this week. Will need sometime to document them though.

addyosmani commented 7 years ago

Awesome. We super appreciate it! On Wed, Sep 28, 2016 at 9:58 PM Eiji Kitamura notifications@github.com wrote:

FYI, I'm testing this week. Will need sometime to document them though.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/WebFundamentals/issues/3466#issuecomment-250370433, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGxaZf6Uk7UtFKvEbUCeUhpDuzfMjlNks5qu0VqgaJpZM4KEcxe .

agektmr commented 7 years ago

Quick summary from my experiment last week:

Firefox desktop and mobile Seems to no longer share the combined quota for local storage and session storage. 10MB each. IndexedDB applied a new quota strategy: https://developer.mozilla.org/en/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria

Safari desktop and mobile Seems that IndexedDB's bug still persists and there's no limit to the storage. All other storage quota stay the same as what we had on LocalStorage, SessionStorage, WebSQL, IndexedDB.

Chrome desktop and mobile Everything stay the same since Chrome 40 except IndexedDB is now compressing the payload. The new Storage API is introduced. It is recommended to use.

Edge Needs research.