- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (3)
- 2.0.3 (18)
- 2.1.0 (4)
- 2.2.1 (0)
- 2.3.8 (3)
- 3.0.0 (14)
- 3.0.9 (-2)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-38)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
Provides methods for linking a HTML page together with other assets, such as javascripts, stylesheets, and feeds.
Constants
JAVASCRIPT_DEFAULT_SOURCES = ['prototype', 'effects', 'dragdrop', 'controls'] unless const_defined?(:JAVASCRIPT_DEFAULT_SOURCES)
Attributes
Alternative hostname generation method
Instead of using a random number to generate the hostname for the single asset, I prefer using source.hash.modulo, so that a given file is always served from the same host. This makes the content more cacheable by browsers and proxies.
ActionController::Base.asset_host = Proc.new { |source| "http://assets#{ source.hash.modulo(9) }.example.com" }
I didn’t benchmark how long it takes, but String#hash should be reasonably fast.
RE: Alternative hostname generation method
According to compute_asset_host as of rails 2.0.0 the %d expansion works in the same way, it’s not a random number generated on each call but the source hash mod 4.
In my brief testing in rails 2.3.9, %d doesn’t appear to work if you use a Proc, so manual generation is of use in that case.

