wingy
wingy

Reputation: 559

Use CDN files with HTML5 app cache

Chrome basically can't retrieve any CDN files (jQuery, AngularJS) I have specified in my index.html since I cannot have them under CACHE: directive (they are not in my domain).

CACHE MANIFEST
# v1.0.7

CACHE:
/partials/account_items.html

How can I make my web app work using app cache but also CDN files?

Upvotes: 2

Views: 2332

Answers (2)

MattH
MattH

Reputation: 41

I use // instead of / for CDN contents that should be part of the application cache. For example, my current project uses fontawesome.io and jquery:

CACHE:
//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css
//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0
//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js

Upvotes: 4

Greg Wilson
Greg Wilson

Reputation: 2410

If I'm understanding you correctly, you need a NETWORK section and add the domains where the jquery/angularJS is stored.

For example - both angularJS and JQuery are hosted on ajax.googleapis.com. Assuming that's the CDN you are using, simply add that host to the NETWORK section of your cache manifest:

NETWORK:
http://ajax.googleapis.com

I blogged about this and other aspects of app cache at http://gregsramblings.com/2012/05/28/html5-application-cache-how-to/

Greg

Upvotes: 2

Related Questions