Is there a way to Increase HTML5 Storage quota - html

I've been trying and searching for a way to increase the native quota on Safari (both iOS & Desktop), and Chrome, I've tried with no success and searched almost everywhere.
I'm working on a web-app that supposed to work offline most of the time, so at the user's first login, I retrieve the contents and store them within pre-defined databases (using IndexedDB), the problem here is that the app's content may be larger than 30MB.
Is there any way to prompt the user to increase his quota so it fits my app's needs, as long as I understand that there's no way to force a specific quota with out his permission ?
Thanks in advance.

With Chrome (and soon Firefox) you can use APIs to query the quota and how much is used:
From Chrome M61 on (and future Firefox) - spec:
navigator.storage.estimate().then(
(used, total) => console.log(
`using ${used} out of ${total}, or ${used/total*100}%`
)
);
Older Chrome only:
navigator.webkitTemporaryStorage.queryUsageAndQuota(
(used, total) => console.log(
`using ${used} out of ${total}, or ${used/total*100}%`)
);
How much quota an origin is granted by Chrome varies depending on device storage capacity (to balance multiple competing sites and not fill the device). There is no API or prompt to increase storage.
Safari doesn't support the estimate() API yet and likely has different rules/heuristics for granting quota.

Related

The quota size of offline storage in chrome

I have only been using indexedDB for a few day and I have a question about the limit of indexedDB. I have read a lot of documents on the internet and this is what I got:
The quota size of storage
Get the size of storage
Turn the persistent mode on
But I can not find any information about how to change the quota size of storage(at least in chrome).
Can we change the quota size of storage?
Not in Chrome. Quota is determined by a heuristic, sites and users can't alter it.
Your best resource to learn more is probably: https://web.dev/storage-for-the-web/

HTML5 sessionStorage limits?

A few questions regard HTML5's sessionStorage:
Does the 5MB limit on localStorage include sessionStorage? (ie. is it really a 5MB limit on the WebStorage API)
If not does sessionStorage have a maximum size limit similar to localStorage?
I found this site http://dev-test.nemikor.com/web-storage/support-test/ in another SO questions, I'm wondering if the data is still relevant?
Does the 5MB limit on localStorage include sessionStorage? (Answer: NO)
is it really a 5MB limit on the WebStorage API (Answer: NO; Supported By )
does sessionStorage have a maximum size limit similar to localStorage? (Answer: NO; Supported By )
Hope I answered all your questions in a simplified manner. Here is a particularly informative section for you:
QUOTAS
You can imagine the chaos if any website was allowed to
populate unsuspecting hard drives with gigabytes of data! Thus,
browsers impose limits on storage capacity. When your app attempts to
exceed that limit, the browser will typically show a dialog to let the
user confirm the increase. You might expect the browser to enforce a
single limit for all storage an origin can use, but the major browsers
are actually enforcing limits separately for each storage mechanism.
This may change in the future, but for now, you should think of the
browser as maintaining a 2-D matrix, with "origin" in one dimension
and "storage" in the other. For example, "http://abc.example.com" is
allowed to store up to 5MB of Web Storage, 25MB of Web SQL Database
Storage, and forbidden to use Indexed Database. Another welcome
enhancement in this area would be user interfaces to let users view
and control how much space they have allocated for each origin. There
are also environments where the user can see upfront how much storage
will be used, e.g. in the case of the Chrome Web Store, when a user
installs an app, they will be prompted upfront to accept its
permissions, which include storage limits. One possible value is
"unlimited_storage".
The above text taken from http://www.html5rocks.com/en/tutorials/offline/storage/

HTML5 Database - increase size above 5mb without prompting to user

Is there anyway to change the html5 DB storage space from 5mb without asking the user ? (I'm interested most for Firefox browser)
Short answer is no.
You could however use IndexedDB...
IndexedDB:
Browsers will ask the user for permission if the DB tries to use more than their specified limit (50MB in Firefox's case I think). Once permission is obtained there is no further permission requests though.
LocalStorage:
The limit is 5MB for all browsers. This cannot be changed.

When is localStorage cleared?

How long can I expect data to be kept in localStorage. How long will an average user's localStorage data persist? If the user doesn't clear it, will it last till a browser re-install?
Is this consistent across browsers?
localStorage is also known as Web Storage, HTML5 Storage, and DOM Storage (these all mean the same thing).
localStorage.setItem('bob', varMyData);
sessionStorage.setItem('bob', varMyData);
localStorage is similar to sessionStorage, except that data stored in localStorage has no expiration time, while data stored in sessionStorage gets cleared when the browsing session ends (i.e. when the browser / browser tab is closed). (See Limitations section below for up-to-date storage size limitations.)
Session storage is used much less often than localStorage, and exists only within the current browser tab - even two tabs loaded with the same website will have different sessionStorage data. sessionStorage data survives page refresh, but not closing/opening the tab. LocalStorage data, on the other hand, is shared between all tabs and windows from the same origin. LocalStorage data does not expire; it remains after the browser is restarted and even after OS reboot.
localStorage is available on all browsers, but persistence is not consistently implemented. In particular, localStorage can be cleared by user action and may be cleared inadvertently (who would think that clearing all cookies also clears localStorage?).
In Firefox, localStorage is cleared when these three conditions are met: (a) user clears recent history, (b) cookies are selected to be cleared, (c) time range is "Everything" -- or when LocalStorage is full - see "Limitations" section below.
In Chrome, localStorage is cleared when these conditions are met: (a) clear browsing data, (b) "cookies and other site data" is selected, (c) timeframe is "from beginning of time" -- or when LocalStorage is full (see "Limitations" section below). In Chrome, it is also now possible to delete localStorage for one specific site.
In IE, to clear localStorage: (a) Tools--Internet Options, (b) General tab, (c) delete browsing history on exit, (d) ensure "Cookies and website data" (or "temporary internet files and website files") is selected, (e) consider unchecking "Preserve Favorites website data" at the top
In Safari: (a) Click Safari (b) Preferences (c) Select the Privacy tab (d) Click Remove all website data (e) Click Remove Now
Opera: Despite excellent articles on localStorage from the Opera site, I haven't yet found clear (non-programmatic) instructions to users on how to clear localStorage. If anyone finds, please leave a comment below this answer with reference link.
Limitations:
TOTAL localStorage is limited to 50% of free disk space.
ALSO, the localStorage for any one "origin" (domain + any subdomains) is (theoretically) limited to 20% of total localStorage - in practice, though, the localStorage for one domain (as of Oct/2022) is:
minimum: 10Mb
maximum: 2Gb Source
actual: 5Mb (limit on my system with 6Gb free space, per a modified version of this script )
(Test System: i7 / 32Gb / 500Gb SSD w 6Gb free / Brave browser:
Version 1.45.133 Chromium: 107.0.5304.141 (Official Build) (64-bit)
When the TOTAL localStorage is full, then the browser will start clearing out data (called "origin eviction") based on an LRU policy — the Least Recently Used domain will be deleted first, then the next one, until the browser is no longer over the limit.
Note that this origin eviction process will delete an entire domain's worth of data until the storage amount goes under the limit again. Deletion of a domain's localStorage data is "all-or-nothing" -- there is no trimming effect put in place to delete parts of origins (domains) because partial data could be much worse than no data.
The Opera dev site has an excellent summary of localStorage:
The current way of storing data on the client-side — cookies — is a
problem:
Low size: Cookies generally have a maximum size of around 4 KB, which
is not much good for storing any kind of complex data
It’s difficult for cookies to keep track of two or more transactions on the same
site, which might be happening in two or more different tabs
Cookies
can be exploited using techniques such as cross site scripting,
resulting in security breaches
Other (less popular) alternatives to
cookies include techniques involving query strings, hidden form
fields, flash based local shared objects, etc. Each with their own set
of problems related to security, ease of use, size restrictions etc.
So up until now we have been using pretty bad ways of storing data on
the user’s end. We need a better way, which is where Web Storage comes
in.
Web Storage
The W3C Web Storage specification was designed as a better way of
storing data on the client-side. It has two different types of
storage: Session Storage and Local Storage.
Both Session and Local Storage will typically be able to store around
5 MB of data per domain, which is significantly more than cookies. NOTE THAT although MDN's numbers were updated (Oct 2022) and now say: minimum: 10Mb / Maximum: 2Gb, this author is unable to exceed 5Mb per domain/origin. M.D.N. / test script
Resources:
https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
MDN - Browser_storage_limits_and_eviction_criteria
https://javascript.info/localstorage
https://dev.opera.com/articles/web-storage/
http://www.quirksmode.org/html5/storage.html
http://www.ghacks.net/2015/02/05/how-to-clear-web-storage-in-your-browser-of-choice/
https://nakedsecurity.sophos.com/2014/11/05/how-to-clear-out-cookies-flash-cookies-and-local-storage/
http://www.opera.com/dragonfly/documentation/storage/
DOMStorage article on MDN (written by John Resig)
http://ejohn.org/blog/dom-storage/
W3C draft says this
User agents should expire data from the local storage areas only for security reasons or when requested to do so by the user. User agents should always avoid deleting data while a script that could access that data is running.
So if browsers follow the spec it should persist untill the user removes it on all browsers, I have not found any that have deleted on any off my projects.
A good article to read is also http://ejohn.org/blog/dom-storage/
Duration
Unlimited. The data persists through browser & OS restarts.
Capacity
Each domain can store minimum of 5MB of data in LocalStorage.
For some browsers you can store up to 1GB of data.
In Chrome while performing 'clear browsing data' , if you choose 'Cookies and other site and plugin data' option then sessionStorage data will be erased.
The content in localstorage is persistent as long as the user chooses to clear the storage (entirely or a single value inside it)
About the consistency across browser, localstorage is currently available on every major browser, including IE8+ (see http://caniuse.com/#feat=namevalue-storage)

Mobile Safari 5mb HTML5 application cache limit?

It's becoming evident in my testing that there's a 5mb size limit on Mobile Safari's implementation of HTML5's application cache.
Does anyone know how to circumvent or raise this? Is there some unexposed meta tag that I should know about? I have to cache some video content for an offline app and 5mb is not going to be enough.
I tried to write a simple test with this manifest:
CACHE MANIFEST
# 2010-06-20:v4
http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
http://peach.blender.org/wp-content/uploads/big_big_buck_bunny.jpg
http://apod.nasa.gov/apod/image/9712/orionfull_jcc_big.jpg
http://www.thelivingmoon.com/43ancients/04images/Titan/titan5km_huygens_big.jpg
http://upload.yeuamnhac.com/musica/dan_lily/dancontent/rh108poster1big.jpg
This cache will need 11.4MB of storage.
When I open a page include that manifest file, it say something like that: "This website require to use up to 25MB of storage, do you want to increase local storage?".
I think I got what the way iOS do:
You only have 5MB for local storage (include HTML5 application cache)
If your web need more, Safari need user's agreement for some packages (up to 10MB, or 25MB, or more...)
Hope that useful for you.
This won't apply to the particular offline-video use case, but you can create Web SQL databases larger than the default 5MB in iOS by simply requesting a larger DB in the openDatabase call. For some kinds of storage, SQLite can be an acceptable solution.
Also contacted apple about this.
Read my blogpost about this here: http://techblog.viewbook.com/2011/02/mobile-safari-offline-application-cache-limit/
And my StackOverflow post here: Max size iPad / iPhone Offline Application Cache
What else is on the page?
These guys keep their pages under the limit by either splitting up the pages or replacing some of the cached images with links:
http://www.mobilenoter.com/blog/post/2010/04/06/Removing-size-limit-of-a-page.aspx
I ran a web app that was larger then 5MB on an iPad (iOS 5) although it is an iPad once the page loaded past 5MB it presented a pop-up asking the user if he/she wanted to increase the size of the cache to 10MB.
I would appear that with the latest iOS version that if a web app needs more then 5MB of cache storage it will ask the user if it has permission to increase it so the user can manage his/her own memory space.
It would also stand to reason that when you view your usage data (say via iTunes) the amount you see in the "Other" category is probably web cache mostly. Also you can see how much space is being used per website by going to Settings | Safari | Advanced | Website Data.
Not sure why every forgets about the good 'ol Web apps (remember these guys? they were around before native apps!), but they're already "offline ready," which means that you don't need to load up your application cache with every component of your app.
To the best of my knowledge, there is no limit to the size of web apps.
http://www.apple.com/webapps/