Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

asset tag caching breaks setting asset_host to a proc

#1299

I'm using a proc to set the asset_host. I basically want to use ssl if the request is an ssl request, serve assets using the same host as the request if the user is hitting the box directly, and otherwise, use 4 different asset hosts.

The problem is that the cache key in AssetTag.create uses ActionController::Base.asset_host, which is a Proc, but evaluated as a string is always the same. So because of the caching, the Proc isn't being called and is returning the wrong results.


config.action_controller.asset_host = Proc.new do |source, request|
  if request.ssl?
    "#{request.protocol}#{request.host_with_port}"
  elsif request.host_with_port =~ /^ror\d/i
    request.host_with_port
  else
    "asset%d.domain.com" % (source.hash % 4)
  end
end

Reported by Dan Manges · October 30th, 2008 @ 04:42 PM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • State changed from new to committed

    (from [49a055dff639164435dfb71bf18d695970eedac9]) Fixed the AssetTagHelper cache to use the computed asset host as part of the cache key instead of just assuming the its a string [#1299 asset tag caching breaks setting asset_host to a proc state:committed] http://github.com/rails/rails/co...

    January 1st, 2009 @ 05:53 PM

  2. Repository
    Repository

    (from [ee701e0672f5b0978ace900f272b577b45bf826b]) Fixed the AssetTagHelper cache to use the computed asset host as part of the cache key instead of just assuming the its a string [#1299 asset tag caching breaks setting asset_host to a proc state:fixed] http://github.com/rails/rails/co...

    January 1st, 2009 @ 06:20 PM