Here is a very simple example to illustrate my question using jQuery from the CDN to change the page:
<html> <body> <p>Hello Dean!</p> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script>$("p").html("Hello, Gabe!")</script> </body> </html>
When this page loads with an Internet connection, the page displays "Hello Gabe." When I disconnect the Internet connection, the message "Hello Dean" will appear on the page with an error - JQuery is not available.
I understand that CDNs have a long Cache-Control and Expire header response, which, as I understand it, means that the browser caches the file locally.
$ curl -s -D - https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js | head HTTP/1.1 200 OK Server: cloudflare-nginx Date: Fri, 17 Apr 2015 16:30:33 GMT Content-Type: application/javascript Transfer-Encoding: chunked Connection: keep-alive Last-Modified: Thu, 18 Dec 2014 17:00:38 GMT Expires: Wed, 06 Apr 2016 16:30:33 GMT Cache-Control: public, max-age=30672000
But this does not seem to be happening. Can someone explain what is happening? Also - how can I get the browser to use a copy of jQuery in the cache somewhere?
This question arose because we want to use CDN to serve external libraries, but also want to be able to develop the page offline - for example, on an airplane.
I get this behavior using Chrome and Firefox.
html5 caching browser-cache cdn offline-caching
gabe
source share