rcherny wrote on 9/9/2008 7:36 AM:
Hey, I'm implementing jQuery for a fairly large company, and was asked
by their team if we knew if anyone in the Fortune 500 was using the
Google Ajax hosting:

http://code.google.com/apis/ajaxlibs/

They have some IT issues which are preventing proper server
configurations in the short term at least, so this was seen as a way
to help improve things.

However, they seem to be skeptical for some reason...

I don't recommend the Google AJAX hosting to my clients.  Here's why: the 
jQuery library is small to begin with, so we're not talking about saving oodles 
of bandwidth, and if you set the Expires header to expire in a year, then the 
browser will only download it once per year for your site (unless the user 
clears their browser cache):

        http://developer.yahoo.com/performance/rules.html#expires

So assuming the browser's cache isn't cleared, the browser will just use the 
cached version without having to send a HTTP request.  That's as little 
overhead as you can possibly achieve resulting in the best performance.

Google, on the other hand, doesn't use the Expires header, they instead use the 
Last-Modified header.  This means that instead of the browser just outright 
using the cached jQuery library, it first has to ask Google if the file has 
been modified for *every* page on your site that uses the jQuery library.  All 
of those unnecessary HTTP requests (one per page) add overhead and degrade 
performance.  So the irony here is that you will get BETTER performance for 
your users by hosting the jQuery library yourself and using the Expires header.

So why doesn't Google use the Expires header given it would provide the best 
performance?  The only reason to do what Google is doing (using the 
Last-Modified header) would be if the resource could changed at any given 
moment.  But the AJAX libraries are all versioned and will never change (there 
would be a new version).  So that can't be it.  Which leaves us with only one 
other reason (that I can think of) which is the Last-Modified header allows 
Google to track the visitors using your site on every page that uses the jQuery 
library.


- Bil


Reply via email to