Firefox 3’s offline capabilities have been getting some attention lately: Chris Double’s post on porting Zimbra to use offline shows-off the potential. Robert O’Callahan and JohnResig give details on the different pieces of the capabilities, namely: Offline Cache, Offline Events and DOMStorage.

A Simple Demo – Task Helper

I put together a simple offline application sample to help illustrate how the features can work. Call it – explanation through code. The application is a simple task list system. The current functionality includes:

Add tasks – Enter text in field and press ‘Add’

Complete tasks – Mark completed tasks and press ‘Complete’

Remove tasks – Mark tasks and press ‘Remove’

Data is stored as JSON and XHR is used to interact with server (PHP)

Nothing fancy. However, the application is “offline-aware”, meaning:

Application resources (HTML & JS) are tagged as offline cacheable

Before interacting with server, online status is checked. If online, use XHR. If offline, use DOMStorage

Online/Offline status is monitored using events. When the application switches form offline to online, data is resync’ed with the server

There is really nothing fancy about the offline stuff either, but putting it all together does make for a neat application. Using the latest Firefox 3 alpha, you should be able to:

Use the application while online.

Go offline using the “Work Offline” menu. The event log should show that the app went offline

Continue to use the application while offline

Go online using the “Work Offline” menu. The event log should show that the app is back online and has updated the server with any offline changes

If you were using a version of Firefox 3 with the offline cache patch (bug 367447) you would be able to a little more:

Use the application while online.

Go offline using the “Work Offline” menu. The event log should show that the app went offline

Continue to use the application while offline

Restart browser

Switch to offline (or have no network connection)

Enter URL to app (or use a bookmark)

Start using app with data from last session

Switching to online will update the server with offline data

Currently, the offline events only fire when offline is toggled via the “Work Offline” menu. Getting the events to fire by watching the network connection is the goal and would make this much more unobtrusive for the user.

Very cool, Mark. In fact, I daresay that it’s hot. One hopes that the folks from http://www.rememberthemilk.com grab this source and extend it so that it calls out to their API. It would be a great win for their service.

We are still in beta but would love to make out system work with the on/offline feature. Is there anybody who can help us?
We are developing an Open Source Platform similar to salesforce.com Appexchange… have a look:http://www.applicationexchange.com