Persistent MobileSafari Pages

Peter-Paul Koch / @ppk:

OK, I’m now sick [of] Safari iPhone’s lack of cache. I don’t want to reload Google Reader every time I close other tab I read article in.

My iPhone has gigs of unused file system space at any one time. I wish Safari could transparently write pages to disk when memory gets crunched rather than just dumping them, requiring a network reload.

I can’t tell you the number of times I’ve tried to squirrel up a bunch of interesting pages for a flight only to have them all dropped on the floor while I loaded up Settings.app to engage Airplane Mode for takeoff.

※ ※ ※

WebKit already has the ability to create a “web archive” — a serialized version of a page and its related resources, so writing that code isn’t the problem.

More likely the problem is when to write the page out. Obviously, you have to wait until its completely loaded, which can be ambiguous in an Ajax World.

You can’t just start serializing in-memory pages in response to -applicationDidReceiveMemoryWarning: since the machinery to serialize pages takes up precious RAM itself.

So you’d probably need to serialize pages opportunistically, after they’re loaded but before memory pressure forces page eviction.

The issue here is that page serialization is probably heavyweight. Writing to flash is slow and I could easily see serialization blocking the UI, hindering UI (especially scrolling) performance. Battery life may take a bit of a hit as well.

Done naively, it’s easy to imagine an across-the-board UI performance hit with such a feature, and that’s with just ten minutes of off-the-cuff thoughts. So I’m sympathetic why this feature isn’t in MobileSafari yet.

But that doesn’t stop me from wishing for it in iPhone OS 4.0.

Feb 10 2010