<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Dynamically set a domain for a Rails asset host</title>
	<atom:link href="http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/</link>
	<description>class AllYourCode &#60; Us</description>
	<lastBuildDate>Mon, 28 Jun 2010 23:07:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: ngng</title>
		<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/comment-page-1/#comment-781</link>
		<dc:creator>ngng</dc:creator>
		<pubDate>Mon, 28 Jun 2010 23:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/?p=254#comment-781</guid>
		<description>Then spend a little extra time to make it work...the following is my production code. &lt;br&gt;&lt;br&gt;def find_asset_host&lt;br&gt;  if APP_CONFIG[&#039;use_asset_servers&#039;] == true&lt;br&gt;    ActionController::Base.asset_host = Proc.new { &#124;source&#124;&lt;br&gt;        asset_hosts = %w{icarus hades dionysus apollo zeus aphrodite ares poseidon}&lt;br&gt;      &lt;br&gt;        # disable asset host&lt;br&gt;        if is_development?&lt;br&gt;          &quot;&quot;&lt;br&gt;        else&lt;br&gt;          if source.starts_with?(&#039;/content&#039;)&lt;br&gt;            &quot;http://#{asset_hosts[rand(8)]}.#{@site.domain}&quot;&lt;br&gt;          else&lt;br&gt;            &quot;http://assets.#{@site.domain}&quot;&lt;br&gt;          end&lt;br&gt;        end&lt;br&gt;      } &lt;br&gt;  end&lt;br&gt;end</description>
		<content:encoded><![CDATA[<p>Then spend a little extra time to make it work&#8230;the following is my production code. </p>
<p>def find_asset_host<br />  if APP_CONFIG[&#39;use_asset_servers&#39;] == true<br />    ActionController::Base.asset_host = Proc.new { |source|<br />        asset_hosts = %w{icarus hades dionysus apollo zeus aphrodite ares poseidon}</p>
<p>        # disable asset host<br />        if is_development?<br />          &#8220;&#8221;<br />        else<br />          if source.starts_with?(&#39;/content&#39;)<br />            &#8220;http://#{asset_hosts[rand(8)]}.#{@site.domain}&#8221;<br />          else<br />            &#8220;http://assets.#{@site.domain}&#8221;<br />          end<br />        end<br />      } <br />  end<br />end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ngng</title>
		<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/comment-page-1/#comment-769</link>
		<dc:creator>ngng</dc:creator>
		<pubDate>Mon, 28 Jun 2010 15:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/?p=254#comment-769</guid>
		<description>Then spend a little extra time to make it work...the following is my production code. &lt;br&gt;&lt;br&gt;def find_asset_host&lt;br&gt;  if APP_CONFIG[&#039;use_asset_servers&#039;] == true&lt;br&gt;    ActionController::Base.asset_host = Proc.new { &#124;source&#124;&lt;br&gt;        asset_hosts = %w{icarus hades dionysus apollo zeus aphrodite ares poseidon}&lt;br&gt;      &lt;br&gt;        # disable asset host&lt;br&gt;        if is_development?&lt;br&gt;          &quot;&quot;&lt;br&gt;        else&lt;br&gt;          if source.starts_with?(&#039;/content&#039;)&lt;br&gt;            &quot;http://#{asset_hosts[rand(8)]}.#{@site.domain}&quot;&lt;br&gt;          else&lt;br&gt;            &quot;http://assets.#{@site.domain}&quot;&lt;br&gt;          end&lt;br&gt;        end&lt;br&gt;      } &lt;br&gt;  end&lt;br&gt;end</description>
		<content:encoded><![CDATA[<p>Then spend a little extra time to make it work&#8230;the following is my production code. </p>
<p>def find_asset_host<br />  if APP_CONFIG[&#39;use_asset_servers&#39;] == true<br />    ActionController::Base.asset_host = Proc.new { |source|<br />        asset_hosts = %w{icarus hades dionysus apollo zeus aphrodite ares poseidon}</p>
<p>        # disable asset host<br />        if is_development?<br />          &#8220;&#8221;<br />        else<br />          if source.starts_with?(&#39;/content&#39;)<br />            &#8220;http://#{asset_hosts[rand(8)]}.#{@site.domain}&#8221;<br />          else<br />            &#8220;http://assets.#{@site.domain}&#8221;<br />          end<br />        end<br />      } <br />  end<br />end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NewMonarch</title>
		<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/comment-page-1/#comment-768</link>
		<dc:creator>NewMonarch</dc:creator>
		<pubDate>Sun, 27 Jun 2010 12:40:25 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/?p=254#comment-768</guid>
		<description>I really wouldn&#039;t recommend implementing this.  From what I know, the randomized solution above will force assets to be downloaded 3+ times (once for each server) as a user cruises through your website.  It will essentially render browser caching useless.&lt;br&gt;&lt;br&gt;Example:&lt;br&gt;We&#039;re linking to logo.png in the header.&lt;br&gt;Page 1: &lt;a href=&quot;http://icarus.mycoolsite.com/images/logo.png&quot; rel=&quot;lightbox[254]&quot; rel=&quot;nofollow&quot;&gt;http://icarus.mycoolsite.com/images/logo.png&lt;/a&gt;&lt;br&gt;Page 2: &lt;a href=&quot;http://zeus.mycoolsite.com/images/logo.png&quot; rel=&quot;lightbox[254]&quot; rel=&quot;nofollow&quot;&gt;http://zeus.mycoolsite.com/images/logo.png&lt;/a&gt;&lt;br&gt;Page 3: &lt;a href=&quot;http://aphrodite.mycoolsite.com/images/logo.png&quot; rel=&quot;lightbox[254]&quot; rel=&quot;nofollow&quot;&gt;http://aphrodite.mycoolsite.com/images/logo.png&lt;/a&gt;&lt;br&gt;&lt;br&gt;Your browser will interpret this as 3 different files and download it once at Page 1 and again on Page 2 and again on Page 3.  Imagine doing that with every asset on a page.  This is way worse than having a single asset host.&lt;br&gt;&lt;br&gt;The real solution would be to conceive of a way to tie specific assets to specific hosts by filename or id or something.</description>
		<content:encoded><![CDATA[<p>I really wouldn&#39;t recommend implementing this.  From what I know, the randomized solution above will force assets to be downloaded 3+ times (once for each server) as a user cruises through your website.  It will essentially render browser caching useless.</p>
<p>Example:<br />We&#39;re linking to logo.png in the header.<br />Page 1: <a href="http://icarus.mycoolsite.com/images/logo.png" rel="lightbox[254]" rel="nofollow">http://icarus.mycoolsite.com/images/logo.png</a><br />Page 2: <a href="http://zeus.mycoolsite.com/images/logo.png" rel="lightbox[254]" rel="nofollow">http://zeus.mycoolsite.com/images/logo.png</a><br />Page 3: <a href="http://aphrodite.mycoolsite.com/images/logo.png" rel="lightbox[254]" rel="nofollow">http://aphrodite.mycoolsite.com/images/logo.png</a></p>
<p>Your browser will interpret this as 3 different files and download it once at Page 1 and again on Page 2 and again on Page 3.  Imagine doing that with every asset on a page.  This is way worse than having a single asset host.</p>
<p>The real solution would be to conceive of a way to tie specific assets to specific hosts by filename or id or something.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ngng</title>
		<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/comment-page-1/#comment-723</link>
		<dc:creator>ngng</dc:creator>
		<pubDate>Wed, 08 Apr 2009 19:42:03 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/?p=254#comment-723</guid>
		<description>You set your hosts in the hash.</description>
		<content:encoded><![CDATA[<p>You set your hosts in the hash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lin</title>
		<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/comment-page-1/#comment-715</link>
		<dc:creator>Lin</dc:creator>
		<pubDate>Tue, 31 Mar 2009 00:40:43 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/?p=254#comment-715</guid>
		<description>It&#039;s really cool. Does it mean that I can hold more than 4 assets hosting server?</description>
		<content:encoded><![CDATA[<p>It&#39;s really cool. Does it mean that I can hold more than 4 assets hosting server?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pjammer</title>
		<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/comment-page-1/#comment-714</link>
		<dc:creator>pjammer</dc:creator>
		<pubDate>Sat, 14 Mar 2009 18:07:38 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/?p=254#comment-714</guid>
		<description>off topic, but is that your S4???  if so, nice.</description>
		<content:encoded><![CDATA[<p>off topic, but is that your S4???  if so, nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Espen Antonsen</title>
		<link>http://jonathanng.com/ruby-on-rails/dynamically-set-a-domain-for-a-rails-asset-host/comment-page-1/#comment-713</link>
		<dc:creator>Espen Antonsen</dc:creator>
		<pubDate>Sat, 14 Mar 2009 13:37:35 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanng.com/?p=254#comment-713</guid>
		<description>Asset hosts support multiple domains: config.action_controller.asset_host = &quot;assets%d.domain.com&quot;</description>
		<content:encoded><![CDATA[<p>Asset hosts support multiple domains: config.action_controller.asset_host = &#8220;assets%d.domain.com&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
