I have been playing around with the HTML5 offline application cache,
running boundary tests to study browser behaviour in edge cases, specifically to find out about the cache quota.
So what I did is to generate and serve an offline app manifest and add 300 5MB JPEG files to the cache.
public ActionResult Manifest()
{
var cacheResources = new List<string>();
var n = 300;
for (var i = 0; i < n; i++)
cacheResources.Add("Content/" + Url.Content("collage.jpeg?" + i));
var manifestResult = new ManifestResult("1")
{
NetworkResources = new string[] { "*" },
CacheResources = cacheResources
};
return manifestResult;
}
In the beginning, I adding 1000 JPEG files to the cache, Chrome threw an error:
it failed to commit the new cache to the storage due to quota exceeded.
I managed to get the right number by slowly reducing the number of images i uploaded,
I could add 300 JPEG files to the cache without crashing it
Investigating chrome://appcache-internals/, I was shocked to see that for
one single web application, there is a huge cache of 2.3GB!!
It’s really odd to find that the website I visited is downloading
so much data in the background, and as a user it can get quite
disturbing. Chrome, the (17.0.963.83), desktop browser of choice at that moment
didnt warn me or ask my permission that the site wanted to download and cache
so much data on my local storage! It’s quite outrageous.
Because of the aforementioned behaviour about the browser-wide
quota being exceeded, sites stop committing data to the application cache.
Is there a way for the browser to keep track of all these in a more organized
manner? Currently, the ‘first browsed, first reserved’ is quite annoying. My experience
to resolve this case is to use the applicationCache API to
listen for quota errors, and inform the user to browse to
chrome://appcache-internals/ and remove other caches over
the new one.
Have a look at this whitepaper for more information on how Chrome deals with local storage: https://developers.google.com/chrome/whitepapers/storage
Temporary storage is limited to 20% of the total pool per app, and the total pool is limited to 50% of the available disk space so Chrome can never fill a disk. As you add more files to your local disk, Chrome will shrink the total allocated to the temporary storage pool accordingly.