Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to include external files in cache-manifest?

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 :)

like image 602
Richard Avatar asked Aug 27 '11 23:08

Richard


People also ask

Which of the following is not a valid section of app cache manifest?

Which is not the section of manifest? Explanation: If the files are not in cache they come from a list of the files in the network. Cache is the default section.

What does cache do in manifest file?

The CACHE section contains files you want to load and store on the user's machine. The first time the user loads your app, the browser will store all the files in the CACHE section of your app cache manifest.

Which section of the cache manifest lists the files that should be cached?

A manifest can have three distinct sections: CACHE , NETWORK , and FALLBACK . CACHE: This is the default section for entries. Files listed under this header (or immediately after the CACHE MANIFEST ) will be explicitly cached after they're downloaded for the first time.


1 Answers

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.

like image 176
Jan Schejbal Avatar answered Oct 16 '22 23:10

Jan Schejbal