« Back to blog

HTML 5 Cache Manifest and the iPhone

After experimenting with the HTML 5 cache manifest attribute for caching resources on the iPhone for offline access, I found a few issues with the Apple documentation that I wanted to let the public know about. These small discrepancies caused none of my offline resources to load in the web app. Complete all of the steps Apple describes in its support documents. First, make sure you are setting the Mime Type for ".manifest" to "text/cache-manifest". Secondly, make sure you have a valid manifest file. All you need is the words "CACHE MANIFEST" at the top followed by a list of URLs to the resources you want to be cached. This is where the differences occur: 1. Instead of declaring the manifest file as:

<html manifest="myassets.manifest">

Declare it as:

<html manifest="/myassets">

I'm not sure if it was just my server setup, but this allowed the iPhone to see the manifest and start caching the resources. 2. Declare the Mime Type "text/cache-manifest" for both ".manifest" and "manifest":

AddType text/cache-manifest .manifest manifest

Once, again, I'm not sure if this was a specific server issue for me, but I don't think it can hurt. If this helps you, let me know on Twitter or send me an email and I'll think about expanding this article.

Comments (3)

May 20, 2010
Bart said...
I'm trying to get the html5 cache working on an Iphone but it doesnt seem to work. Just a blank page. It works perfectly fine on my desktop and on a HTC Android device. How do i declare the MIME in a simple html document?

My test is here: http://stefvantschip.nl/html5/OfflineCacheTest/Cache.html

May 20, 2010
Rob Szumski said...
Did you add the mime type in your .htaccess file?
May 21, 2010
Bart said...
I dont have a .htaccess file .. what is supposed to be in there?

Leave a comment...