refinery/refinerycms — pull request #2238 by mattolson (2013-04-05 03:57:58+00:00)
Title: Add support for Dragonfly's url_host

This change fixes #2049 by adding configuration support for Dragonfly's url_host setting. If you set this to your CDN or other caching server, your Rails app won't get hit at all for redundant dragonfly requests. I realize that Rack::Cache is in place, but this still allows for a further optimization for image heavy sites.

I chose to stick with Dragonfly's existing configuration because the changes are seamless for the rest of Refinery. The url_host is automatically included by Dragonfly's url method. It also gives flexibility to use a different server for dragonfly images than for other static assets, for example: a passthrough CDN for dragonfly and an S3-based Cloudfront distribution for static assets.

Note that Dragonfly does not support a %d placeholder in the host string like Rails does, it only supports a single host. Also, the string must be a full url starting with the protocol scheme (http or https).