<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Big Red Tin &#187; AJAX</title>
	<atom:link href="http://bigredtin.com/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigredtin.com</link>
	<description>Thoughts about the web and business from the large pantry</description>
	<lastBuildDate>Wed, 08 Feb 2012 06:55:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Caching on the Google AJAX Libraries API</title>
		<link>http://bigredtin.com/2009/caching-on-the-google-ajax-libraries-api/</link>
		<comments>http://bigredtin.com/2009/caching-on-the-google-ajax-libraries-api/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 03:49:41 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://peterwilson.cc/?p=106</guid>
		<description><![CDATA[Using the Google Ajax Libraries API, there are several options for specifying the version numbers of the library you wish to use, for example, three URLs point to the latest version of jQuery.]]></description>
			<content:encoded><![CDATA[<p>Using the <a title="Google Ajax Libraries API" href="http://code.google.com/apis/ajaxlibs/">Google AJAX Libraries API</a>, there are several options for specifying the version numbers of the library you wish to use, for example the following URLs all point to the latest version &#8211; at the time of writing &#8211; of jQuery.</p>
<ol>
<li><a href="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js</a>,</li>
<li><a href="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js">http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js</a>, and,</li>
<li><a href="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js">http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js</a></li>
</ol>
<p>The first uses the latest release in the version 1 tree, the second the latest in the version 1.3 tree, and the third the release 1.3.0 exactly. What I found interesting &#8211; and discovered accidently &#8211; is the browser caching times for each of these urls; the first two are cached for an hour, the third for twelve months.</p>
<p>The vastly different caching times make perfect sense, in the first two cases, the developer is expecting an upgrade to the latest version, and doesn&#8217;t want to wait up to twelve months for it; in the third case the developer doesn&#8217;t expect an upgrade so an extended caching period has no effect.</p>
<p>To take full advantage of the Google servers, as described in a recent article by <a title="3 reasons why you should let Google host jQuery for you" href="http://encosia.com/2008/12/10/3-reasons-why-you-should-let-google-host-jquery-for-you/">Dave Ward</a>, the caching times suggest it&#8217;s best to specify the full version of the library you wish to use.</p>
<h4>google.load Method &#8211; Update Jan 24, 2009</h4>
<p><span id="more-106"></span>Further investigation shows that the Google load method uses the full URL for the less specific version requests, for example the following will load <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">ajax.googleapis.com[...]/1.3.1/jquery.min.js</a>* ? at the time of writing ? and cache the file for twelve months.</p>
<pre><code>&lt;script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
&lt;script&gt;
  /* &lt;![CDATA[ */
  google.load("jquery", "1"); //latest version in the v1 tree
  /* ]]&gt; */
&lt;/script&gt;</code></pre>
<p>The jsapi file is not cached, so a additional 5K is downloaded for every page hit on your website; if a visitor loads more than three pages an hour then the advantage of the longer caching time is lost. As always, it&#8217;s a matter of compromise.</p>
<p>* A minor update to jQuery has been released since the original article was written.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/2009/caching-on-the-google-ajax-libraries-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

