<html manifest="books.offlineManifest">Now create a file named (you guessed it) books.offlineManifest. Place this file in the same directory (at the same level) as index.html. Now the tricky part - modify your web server configuration so that files with the suffix ".offlineManifest" get served not as text/html but as text/cache-manifest. If you're using apache, the command you need to put into the configuration file looks like this:
<!--- your page's html--->
AddType text/cache-manifest .offlineManifest
Restart the server if necessary to reload the config.
Now, inside the books.offlineManifest file, place the following:
Note that the book-title-1.html and the like are, of course, the location of the files that are pointed to by links on your index.html page. These files can be in subdirectories, but be careful - the cache manifest should not contain lines describing the subdirectories, just the files. So for example, do not do the following>
CACHE MANIFEST CACHE: index.html books/ books/book-1.html books/book-2.html...the 'books/' line will cause the caching process to puke and stop. I mention this because, of course, I did it, being lazy and using 'find .' to get my tree info. DON'T BE ME.
All right, once you've got all these files saved to your webserver, use your iPhone and navigate to the index page. Once you've loaded it, click the '+' in Safari and seelct 'Add to Home Screen.' This will create an applet on the iPhone which loads that index. Quit Safari and then click that applet. It will reload Safari and bring up your index page. It will also start traversing the file list in books.offlineManifest and caching them onto your iPhone! Once it has done that, you'll be able to navigate to them using Safari even if the iPhone is not on the network, because Safari will realize it has them cached.
The down sides:
The most annoying thing, for me, is that it picks some strange order of files in my (really long, because I use exploded-by-chapter HTML books) file list. And, it never seems to finish loading my manifest - usually, the phone sleeps, or something silly, or it just stalls - and when it restarts (because I re-navigate to the page) it... starts loading them all over again. It might be most effective to have a manifest and applet per book or per author rather than having everything stuffed into one file. I found that when I limited the manifest to around twenty files, they all loaded fine. There is, however, no real way of telling what's loaded and how far it's gotten, because it's supposed to be invisible to the user (I figured it out by tailing the logs on my webserver while it was caching).
So there you have it. Thanks Dave Camp! Until the Safari file:// patch works on the 2.2 firmware, this is what I'm going to have to do.
Posted by jbz at December 14, 2008 12:58 AM