If I navigate here: http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js
I download 70k using Firefox 3.6.3 and I can confirm it is sending Accept-Encoding: gzip.
If I use the Microsoft one: http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js
I download 30k (and it comes through as Content-Encoding: gzip)
I am also experiencing this when using jquery 1.4.2 in regular sites eg jquery.com. Funily enough, stack overflow which references jquery 1.3.2 on the google cdn, is coming through gzipped.
Why is this happening? Is it some kind of issue with google or am I missing something?
I live in Melbourne, Australia.
EDIT: oops mixed up the links. hmm http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js works for me.. looks like it is just the 1.4 inclusive one
About GZip support on Google's CDN:
Google's CDN supports GZip compression. As far as I know it does not support Deflate, but that does not matter because all major browsers support both.
You can verify this yourself using Rex Swain's very nice HTTP viewer; just enter "gzip" in the Accept-Encoding field.
I have played around a little, and I think that Google's CDN requires browser whitelisting before sending compressed Javascript. If you sometimes see too fat responses from Google's CDN, then maybe this is what tripped you up. If you want to play with this, you can use Rex Swain's viewer again, and put a nonsense string in as User-Agent header.
About the "automatic upgrade" URLs:
IMHO it is not ideal to use the 1.x or 1.4.x links on Google's CDN (the ones without a fully qualified version number).
The first reason is that Google is serving those URLs with a low Cache-Control max-age value of 1 hour. Google of course does this to facilitate quick updates when a new version of jQuery is released. (This may not be as bad for performance as it can initially seem. Google also sends revalidation and Last-Modified headers, so I assume Google's CDN fully supports revalidation.)
The main reason why I don't like the automatic upgrade URLs is this: If you serve jQuery from one of the URLs with automatic upgrades, then you risk unknown incompatibility problems later on. A future version of jQuery could conflict with one of the likely many 3rd party scripts that you're using, and cause your pages to break silently.
Conclusion:
There are reasonable critiques against using Google's CDN. Some teams have a great build process with automatic script combining and minification, as well as a fast global CDN for their content. If you're on one of those teams, then maybe Google's CDN is not the best option for you. But form most 'common' sites, the best way to serve jQuery is to use Google's CDN with a full version identifier.
I'm having it the other way around.
The Google one is 24KB and the MS one is 70KB...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With