I thought along the same lines, but Shai has really nailed the idea. I'd add one thing; DO NOT write two sets of code, one for
working online and a fall back to use when offline. Structure your code to always use the same cycle - update local database,
record "pending" transactions, post pending transations to the real server.