what if tomorrow every site would start using HTML5's application cache? this is an interesting question between there is a quite important difference between caching
and storing
, and while HTML5 technically treats offline applications as caching rather than storing, it is interesting to look at the differences in principle, in their design trade-offs, and in the influence then might have on how successful HTML5 offline applications might become
it's probably fair to say that currently, offline web apps are very rare. apple tried to push them before they allowed native apps on the iPhone, but given the current app craze it's almost in their best interest to not promote the iPhone's offline web app capabilities anymore. android also supports offline web apps, but the browser (at least in 2.1) seems to have problems with reliably firing the relevant events (which is even worse on the iPhone because going offline often requires leaving the browser, and that will stop the browser process anyway). in firefox, it is also supported, but there is a user confirmation popping up, and there does not seem to be any UI support for figuring out which sites have stored data. safari does a better job at that, it allows to explore the local storage that has been used, but there does not seem to be an interface to find pages that use the app cache.
it is obvious that the current state of implementations is in an early stage and rather inconsistent, which is understandable given the lack of popularity for offline web apps.
given that mobile safari's caching is so bad, some web developers suggest to (mis)use app cache to improve the likelihood that mobile safari will do some useful caching. but this approach is hard to deploy for dynamic apps, because the caching information is not carried in HTTP, but in some HTML5-specific file, which means that this file has to be updated and reprocessed by the browser every time a new resource should be cached. that's the price of HTML5's approach to pull caching into the HTML layer (where it very likely does not belong). but let's assume web developers worldwide start doing this, because better caching on mobile devices results in a dramatically improved user experience. mobile safari would then very soon run into issues of having too much to store, and would have to purge cached pages from the app cache as well because of some upper limit of cache capacity. that might also mean that some web app that the user really wanted to use offline might get purged from the cache.
the reason for this problem is that there currently is no way how a user is supposed to confirm that a web app should have the right to use the app cache and local storage (firefox is the only browser implementing such a confirmation). mobile safari might implement a different policy in how it handles apps depending on whether they are merely bookmarked, or installed
in the iPhone UI. while this probably should be the difference between whether an offline web app is cached (i.e., might be purged if storage space runs low) or stored (i.e., is never purged and thus treated like a locally installed app), maybe it would be useful to have a more well-defined model for this, so that browsers would behave consistently.
in browsers not as integrated into the OS as mobile safari, the browser itself might have a springboard
that would show all installed
offline apps, and these apps would never expire from the cache until explicitly de-installed
(removed), and they probably implicitly should get the permission to use local storage which also would never expire. The problem with this approach is that it produces a very different experience from the usual web experience, but it seems to me that if you want offline web apps to become useful and popular, they need a more well-defined framework and more dependability. if i want to use a web app offline, i have to be willing to give it some resources, but i also want to have control over what i did previously, and i want to be able to monitor and revoke permissions.
from the research side of things, it would be interesting to look into how to bridge this typical HTML5 approach of building an app
that just does whatever it has to do, with REST, the architectural style of the web. would it be possible to develop frameworks (maybe layered on top of local storage) that would allow apps to transparently (within certain boundaries, of course) interact with local storage as if they were connected? and then they could simply sync
when the browser goes to online mode? building this would definitely require a number of trade-offs, but having a framework that would support a RESTful and thus web-friendly way of building apps that could more easily switch between offline and online mode, that might be the one thing that's missing to make offline web apps more easy to develop.
for the user, there still is this basic uncertainty what exactly the browser is storing in terms of app cache and local storage, how to grant or revoke permissions for that, and how to understand and control the fundamental difference between caching
and storing
data. it's perfectly fine for a cache to be transparent, but not so much for storage.
"would it be possible to develop frameworks (maybe layered on top of local storage) that would allow apps to transparently (within certain boundaries, of course) interact with local storage as if they were connected?"
You probably know of this, but nevertheless - check out http://www.w3.org/TR/DataCache/. "This document defines APIs for off-line serving of requests to HTTP resources using static and dynamic responses. It extends the function of application caches defined in HTML5." Sounds like there's a lot of pieces of the puzzle available.
Posted by: Ivan Zuzak | Monday, April 26, 2010 at 03:30
How much can web cache store per webpage anyway? BTW, is your shift button broken?
Posted by: Sefi | Friday, June 04, 2010 at 16:54
Interesting read, thanks.
Regarding Firefox, which you say has no "UI support for figuring out which sites have stored data". Perhaps this has changed since you wrote the article. In my Firefox 3.6.6 on the Mac, under Advanced - Network, it shows me "The following websites have stored data for offline use" and lists them in a box with a 'remove' button.
Unfortunately, clicking this remove button doesn't actually remove the cache. It removes it from the box, but if you go to about:cache or check the directory itself, you'll see the entries are still there. That was making me rather frustrated earlier today!
So, I agree it seems there's a long way still to go until browsers provide a good interface for all this. And not just for the end-user, but also for developers (e.g. it would save lots of banging heads against walls if it told you what the problem is when your cache manifest file is invalid).
Posted by: Poshaughnessy | Wednesday, July 14, 2010 at 08:08
regarding browser controls: i am sure these are evolving very quickly. one thing i have noticed in the latest windows version of safari: it does have a preferences panel for "show databases", but that seems to display only SQL databases, and not the key/value local storage. since (current) HTML5 has decided to support both types of databases (and both are implemented in safari), it definitely makes no sense to have APIs for both types of databases, but a management UI for only one of them (and it's not even explained anywhere, you have to test and see what shows up in the panel and what doesn't).
Posted by: dret | Wednesday, July 14, 2010 at 13:41
i have created this .html home page and open it in ipad safari and use option add to home screen and i got a icon like as app. now wanted this page should open while offline (without internet) using casche. is that possible?
Posted by: milind | Friday, August 24, 2012 at 05:02