# Asset\_host with HTTPS problem, or possibly layout being cached?

**URL:** <https://www.ruby-forum.com/t/asset-host-with-https-problem-or-possibly-layout-being-cached/155179>\
**Category:** Rails\
**Created:** [December 9, 2008, 1:51am UTC](https://www.ruby-forum.com/t/asset-host-with-https-problem-or-possibly-layout-being-cached/155179 "2008-12-09T01:51:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LemmingJoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6f9a4e/32.png) [@LemmingJoel](https://www.ruby-forum.com/u/LemmingJoel)\
**Post date:** [December 9, 2008, 1:51am UTC](https://www.ruby-forum.com/t/asset-host-with-https-problem-or-possibly-layout-being-cached/155179/1 "2008-12-09T01:51:28Z")

</div>

I’m having some trouble with either the asset\_host feature or possible  
something to do with layout caching.

I have this in my environment/production.rb:

ActionController::Base.asset\_host = Proc.new do |source, request|  
if request.ssl?  
“https://#{request.host\_with\_port}”  
else  
“[http://asset](http://asset)#{source.hash % 4}.mydominname.com”  
end  
end

When I visit a page using HTTPS, some assets are pointing to a HTTPS  
url, and others to a HTTP url. It turns out the contents of the layout  
produces the HTTP urls, and the page action produces the HTTPS urls.

Perhaps the layout is being cached?? I need all assets pointing to  
HTTPS urls when the page is requested using HTTPS, and likewise, I  
need all assets pointing to HTTP urls when the page is requested using  
HTTP.

Any thoughts as to why this is happening?
