--- !ruby/object:RI::ClassDescription 
attributes: []

class_methods: 
- !ruby/object:RI::MethodSummary 
  name: register_javascript_expansion
- !ruby/object:RI::MethodSummary 
  name: register_javascript_include_default
- !ruby/object:RI::MethodSummary 
  name: register_stylesheet_expansion
comment: 
- !ruby/struct:SM::Flow::P 
  body: This module provides methods for generating HTML that links views to assets such as images, javascripts, stylesheets, and feeds. These methods do not verify the assets exist before linking to them.
- !ruby/struct:SM::Flow::H 
  level: 3
  text: Using asset hosts
- !ruby/struct:SM::Flow::P 
  body: By default, Rails links to these assets on the current host in the public folder, but you can direct Rails to link to assets from a dedicated assets server by setting ActionController::Base.asset_host in your <tt>config/environment.rb</tt>. For example, let's say your asset host is <tt>assets.example.com</tt>.
- !ruby/struct:SM::Flow::VERB 
  body: "  ActionController::Base.asset_host = &quot;assets.example.com&quot;\n  image_tag(&quot;rails.png&quot;)\n    =&gt; &lt;img src=&quot;http://assets.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;\n  stylesheet_link_tag(&quot;application&quot;)\n    =&gt; &lt;link href=&quot;http://assets.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: This is useful since browsers typically open at most two connections to a single host, which means your assets often wait in single file for their turn to load. You can alleviate this by using a <tt>%d</tt> wildcard in <tt>asset_host</tt> (for example, &quot;assets%d.example.com&quot;) to automatically distribute asset requests among four hosts (e.g., &quot;assets0.example.com&quot; through &quot;assets3.example.com&quot;) so browsers will open eight connections rather than two.
- !ruby/struct:SM::Flow::VERB 
  body: "  image_tag(&quot;rails.png&quot;)\n    =&gt; &lt;img src=&quot;http://assets0.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;\n  stylesheet_link_tag(&quot;application&quot;)\n    =&gt; &lt;link href=&quot;http://assets3.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: To do this, you can either setup 4 actual hosts, or you can use wildcard DNS to CNAME the wildcard to a single asset host. You can read more about setting up your DNS CNAME records from your ISP.
- !ruby/struct:SM::Flow::P 
  body: "Note: This is purely a browser performance optimization and is not meant for server load balancing. See http://www.die.net/musings/page_load_time/ for background."
- !ruby/struct:SM::Flow::P 
  body: Alternatively, you can exert more control over the asset host by setting <tt>asset_host</tt> to a proc that takes a single source argument. This is useful if you are unable to setup 4 actual hosts or have fewer/more than 4 hosts. The example proc below generates http://assets1.example.com and http://assets2.example.com randomly.
- !ruby/struct:SM::Flow::VERB 
  body: "  ActionController::Base.asset_host = Proc.new { |source| &quot;http://assets#{rand(2) + 1}.example.com&quot; }\n  image_tag(&quot;rails.png&quot;)\n    =&gt; &lt;img src=&quot;http://assets2.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;\n  stylesheet_link_tag(&quot;application&quot;)\n    =&gt; &lt;link href=&quot;http://assets1.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: The proc takes a <tt>source</tt> parameter (which is the path of the source asset) and an optional <tt>request</tt> parameter (which is an entire instance of an <tt>ActionController::AbstractRequest</tt> subclass). This can be used to generate a particular asset host depending on the asset path and the particular request.
- !ruby/struct:SM::Flow::VERB 
  body: "   ActionController::Base.asset_host = Proc.new { |source|\n     if source.starts_with?('/images')\n       &quot;http://images.example.com&quot;\n     else\n       &quot;http://assets.example.com&quot;\n     end\n   }\n  image_tag(&quot;rails.png&quot;)\n    =&gt; &lt;img src=&quot;http://images.example.com/images/rails.png&quot; alt=&quot;Rails&quot; /&gt;\n  stylesheet_link_tag(&quot;application&quot;)\n    =&gt; &lt;link href=&quot;http://assets.example.com/stylesheets/application.css&quot; media=&quot;screen&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;\n"
- !ruby/struct:SM::Flow::P 
  body: The optional <tt>request</tt> parameter to the proc is useful in particular for serving assets from an SSL-protected page. The example proc below disables asset hosting for HTTPS connections, while still sending assets for plain HTTP requests from asset hosts. This is useful for avoiding mixed media warnings when serving non-HTTP assets from HTTPS web pages when you don't have an SSL certificate for each of the asset hosts.
- !ruby/struct:SM::Flow::VERB 
  body: "  ActionController::Base.asset_host = Proc.new { |source, request|\n    if request.ssl?\n      &quot;#{request.protocol}#{request.host_with_port}&quot;\n    else\n      &quot;#{request.protocol}assets.example.com&quot;\n    end\n  }\n"
- !ruby/struct:SM::Flow::H 
  level: 3
  text: Using asset timestamps
- !ruby/struct:SM::Flow::P 
  body: By default, Rails will append all asset paths with that asset's timestamp. This allows you to set a cache-expiration date for the asset far into the future, but still be able to instantly invalidate it by simply updating the file (and hence updating the timestamp, which then updates the URL as the timestamp is part of that, which in turn busts the cache).
- !ruby/struct:SM::Flow::P 
  body: "It's the responsibility of the web server you use to set the far-future expiration date on cache assets that you need to take advantage of this feature. Here's an example for Apache:"
- !ruby/struct:SM::Flow::P 
  body: "# Asset Expiration ExpiresActive On &lt;FilesMatch &quot;\\.(ico|gif|jpe?g|png|js|css)$&quot;&gt;"
- !ruby/struct:SM::Flow::VERB 
  body: "  ExpiresDefault &quot;access plus 1 year&quot;\n"
- !ruby/struct:SM::Flow::P 
  body: "&lt;/FilesMatch&gt;"
- !ruby/struct:SM::Flow::P 
  body: Also note that in order for this to work, all your application servers must return the same timestamps. This means that they must have their clocks synchronized. If one of them drift out of sync, you'll see different timestamps at random and the cache won't work. Which means that the browser will request the same assets over and over again even thought they didn't change. You can use something like Live HTTP Headers for Firefox to verify that the cache is indeed working (and that the assets are not being requested over and over).
constants: 
- !ruby/object:RI::Constant 
  comment: 
  name: ASSETS_DIR
  value: "defined?(Rails.public_path) ? Rails.public_path : \"public\""
- !ruby/object:RI::Constant 
  comment: 
  name: JAVASCRIPTS_DIR
  value: "\"#{ASSETS_DIR}/javascripts\""
- !ruby/object:RI::Constant 
  comment: 
  name: STYLESHEETS_DIR
  value: "\"#{ASSETS_DIR}/stylesheets\""
- !ruby/object:RI::Constant 
  comment: 
  name: JAVASCRIPT_DEFAULT_SOURCES
  value: "['prototype', 'effects', 'dragdrop', 'controls'].freeze unless const_defined?(:JAVASCRIPT_DEFAULT_SOURCES)"
full_name: ActionView::Helpers::AssetTagHelper
includes: []

instance_methods: 
- !ruby/object:RI::MethodSummary 
  name: auto_discovery_link_tag
- !ruby/object:RI::MethodSummary 
  name: image_path
- !ruby/object:RI::MethodSummary 
  name: image_tag
- !ruby/object:RI::MethodSummary 
  name: javascript_include_tag
- !ruby/object:RI::MethodSummary 
  name: javascript_path
- !ruby/object:RI::MethodSummary 
  name: path_to_image
- !ruby/object:RI::MethodSummary 
  name: path_to_javascript
- !ruby/object:RI::MethodSummary 
  name: path_to_stylesheet
- !ruby/object:RI::MethodSummary 
  name: stylesheet_link_tag
- !ruby/object:RI::MethodSummary 
  name: stylesheet_path
name: AssetTagHelper
superclass: 
