Q:

html5 appcache: does remote manifest file work?

Our application is deployed to the physical device, so the starting page index.html is sitting in the storage of a device, and this file will reference remotely hosted JavaScript files and other resources. That is, the index.html itself is not hosted in our web server. Is it possible to use the html5 application cache in this scenario? That is, the html element would look like this:
<html manifest="http://remotehost.com/site.manifest">

Is this supported? Or is there a workaround to make it work if our web server is not hosting the index.html?
Thanks!

A:

Check this site for basic requirements and limitations:
http://appcachefacts.info/
There are a few things that prevents the appcache to work when your files are deployed to the device's storage:

Cross-Origin-Policy: You are referencing the manifest file from another origin -> not allowed
WebKit: I assume that your WebView rendering the index.html is WebKit powered (iOs/Android). I made some tests with Safari and Chrome on a Desktop PC and figured out that the manifest is ignored if the index.html is served from http://localhost or file://... URLs even if the manifest respected the Cross-Origin-Policy. This will hit you since the locally deployed index.html on your device will served by file://... in most cases.

So I came up with the idea to download the manifest to the device and reference it in my index.html. This leads to some additional problems which I was not able to fix (My setup was PhoneGap, jQueryMobile, iOS):

Mime-Type: You can't ensure that the manifest (served from the device's storage) is served with the right mime-type headers but without them, the browser will ignore the manifest.
Manifest-URI: There is no way you can (hardcoded) distribute an index.html file with a predefined manifest="uri/to/appCacheManifest.manifest" attribute (because you need to download and save it from your server before you know this uri). Additionally you can't manipulate your assets distributed with the PhoneGap application (the www folder) to change the attribute in some way.

Until now I could not get the manifest to work within the PhoneGap WebView. I read some articles where people mentioned the (iOS) WebView is not able to work with the manifest files but this is not correct. If you navigate to a webapplication via the mobile Browser and save a bookmark on your homescreen, iOS embeds this site into a WebView. I tried this with my application (served by a webserver; not embeded in PhoneGap) and the Manifest worked just fine.
This means if you are able to move your files that are "sitting in the storage of a device" to a webserver and you set up a native WebView to point to that location, the manifest should work fine.

