Re:Tell HN: Catalog of JavaScript libraries and CSS resource...
by MicahWedemeyer on Sunday February 28, 2010 @07:42PM
(#1157785)
Thanks for the reply. I took a look at the headers returned for https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.mi... and here's what I see:
Content-Type: text/javascript; charset=UTF-8
Last-Modified: Tue, 09 Feb 2010 23:05:02 GMT
Date: Mon, 01 Mar 2010 00:09:20 GMT
Expires: Mon, 28 Feb 2011 21:55:22 GMT
Cache-Control: public, max-age=31536000
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
Server: sffe
Content-Encoding: gzip
X-XSS-Protection: 0
200 OK
It looks like Google is setting an expires for 1 year in the future, meaning (I believe) that the browser will use the cached copy. So, by using these libraries, you have a decent chance that a brand new visitor will arrive with a warm cache, thereby speeding up that initial page load (and first impression!) a tiny fraction.
It depends on the CDN and what cache information it returns. I'm not going through all the links and verifying that they all return correctly. I do recall Yahoo's YUI documentation page promising the use of far-future Expires which means that the browser very likely never even hits the CDN, but nothing stops the CDN from using E-Tags instead, which is still pretty fast but does manifest as a hit on the CDN they could track. That said, it's entirely possible that every link there uses far-future Expires.
Personally, I'd just grab the file and use far-future Expires myself. If you've got a web application that uses code that way, odds are this is not going to be your bottleneck anyhow; far-future Expires just as thoroughly fails to hit your server as it fails to hit the CDN.