I am using jQuery from google CDN.
I looked at the cache-control and it seems the browser should fully cache the jQuery version for a long time.
However when I disable Internet access my webpages stop working. Why?开发者_高级运维 Is it because even though jQuery is cached, the browser still needs to resolve DNS?
Your brower doesn't need to respect the cache-control header. That is mostly used by proxies. If you want to check whether your browser is keeping a local copy of the script, go into offline mode (in your browser) and try if your website still works.
In addition you might want to enable the Firebug (if you're using Firefox) Net panel to see the exact request your browser sends to the server (and what the response is).
There are a few layers of cache. Just because it is cached for a long time doesn't mean it won't ask the server and check to see if it is the latest edition.
Additionally, offline mode in your browser may not even attempt to load files that it determines to be non local.
精彩评论