Question

I'm building an offline web application and want to use cache-manifest. Currently my cache-manifest looks like this:

CACHE MANIFEST
# Change the version number below each time we update a resource.
# Rev 1
index.html
photo.html
js/photo.js
css/photo.css
http://code.jquery.com/jquery-1.6.1.min.js
http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js
http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css
http://maps.google.com/maps/api/js?sensor=false&region=GB

Is there any reason not to include external, CDN-hosted jQuery, jQuery Mobile and Google Maps files in the cache-manifest?

I can't think of one, but I thought I would ask those wiser than myself :)

Was it helpful?

Solution

You cant. Cache Manifest will only work for files from same domain. You would need to proxy from your domain if you want to white-list for cross-domain resources.

OTHER TIPS

Yes. Actually, you must include external images in your manifest, or some browsers will not load them at all even if a network connection is available! (Unless you provide a NETWORK section, which may cause the images to be fetched every time, bypassing the regular browser cache.)

The images will be cached (at least by Firefox, didn't test Chrome).

The spec explicitly says:

Offline application cache manifests can use absolute paths or even absolute URLs

http://manifest-validator.com/ also reports a manifest with external URLs as OK.

I am not 100% sure this also applies to scripts, but a quick test with Firefox looked like the script is cached as expected.

MobileSafari has a rule that under SSL, all paths in the applicationCache must conform to same-origin policy. The applicationCache will cache successfully with foreign-origin paths, but you will not see those resources listed in the Web Inspector->Storage->ApplicationCache table, and they will not be available when offline.

This behavior isn't described in Apple's documentation but is still apparent in iOS 10.2: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/SafariJSDatabaseGuide/OfflineApplicationCache/OfflineApplicationCache.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top