Saturday, 30 April 2011

Mobile, Web Client Storage And Offline

Desktops and laptops will be mostly connected to the internet. So almost all software written today targeted for desktops and laptops is web based. For mobile apps, that is much more tricky. Mobile devices are used when people are on the move. While general connectivity coverage is increasing, it will still take quite a couple of years before all planes, trains and stations give you decent broadband required by today's apps.

For mobile apps it's a tough choice between HTML 5 and native apps. Native apps don't require to be connected, but you need to develop one for every platform (at least Android and iOS).

Martin Fowler's blog CrossPlatformMobile makes the valid point that cross platform toolkits are no attractive alternative. But then there is this section that really confuses me
The biggest issue here is offline use. If you can live with online all the time, then this won't be a problem, but you need offline you'll need to explore the various local storage options.
This seems to suggest that the local storage options to some extend would be able to reduce the need for connectivity. That would decide the mobile platform battle in favour of HTML 5 easily. But I still don't see how storage on the client side helps to remove the need for connectivity. If you load a webapp before you go offline, then it is possible to keep it running on local storage when connectivity is down. That is a nice extension to webapps.

But afaict it doesn't give the ability to work offline because loading the app still requires connectivity and a refresh gives a 404 page not found without the possibility to get the app back in the browser. Also the linked article doesn't really provide a solution for this.

Given that the respected Martin Fowler seems to indicate that web storage has to be looked at as a solution for offline usage of webapps, I assume I must be missing something. But what ?

I'm in general puzzled why browsers are so bad at using caches when working offline. Yet it seems like a solvable solution for browsers to use their cache to overcome these 2 obstacles of loading the app and refresh and make HTML 5 the ultimate mobile platform.

Do you see a solution so that HTML 5 becomes a valid mobile technology option that also covers offline usage?


  1. there are 3 kinds of storage you should look at for offline web-apps; localstorage (key/value-pairs, values can be json-ified objects/ arrays), indexeddb (new database-like storage, replaces webdb which was sqlite-specific) and appcache.

    that last one allows one to store html, css, js, images, ... on the client. combine that with localstorage (or indexeddb, but that's not broadly supported yet) and you've got a true offline webapp (cfr. this small experiment of mine)

  2. Hi Frank,

    The trappist db example is really inspiring! Exactly what I was looking for. Both on the tech and the beer side ;-)

    Tijs, my new collegue, also mentioned that offline can be combined with client storage.

    Localstorage together with appcache looks like what I was looking for!

    Would be really cool if webapp frameworks like Vaadin could take advantage of localstorage and appcache to build apps that can work offline and then sync when reconnected.

  3. Hey Tom, I just read your post again and remembered this HTML 5 slideshow I came across a few days ago: (use left + right cursors to navigate). It shows the different offline storage features of HTML 5 along with a bunch of other interesting stuff...