This project is archived and is in readonly mode.

#1299 ✓committed
Dan Manges

asset tag caching breaks setting asset_host to a proc

Reported by Dan Manges | October 30th, 2008 @ 04:42 PM | in 2.x

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

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Tags

Referenced by

Pages