4 ms·
If you are running Rails on Heroku, use this gem to properly serve assets.
- Michikono 14y agoI think this is a better suggestion: https://github.com/rumblelabs/asset_sync https://github.com/rumblelabs/asset_sync It uploads all your assets to S3 during pre-compile. It keeps ALL of the asset loading logic off your application. Also, it uploads .gz versions of all assets.
- jbaudanza 14y agoThere are a few reasons I don't do this. For one, deploys take longer. Also S3 isn't able to negotiate the Accept-Encoding header. So you have to assume that all your clients will be able to handle gzipped assets. You can use your app as a root origin for your assets, and then use something like CloudFront to offload most of the work.
- Michikono 14y agoFor the record, serving assets off S3 directly isn't a good idea. We use cloud front for that as well. Making the actual app the root origin is a good idea though. Need to think a little about the full ramifications of that versus simply having the S3 asset bucket the origin.
- tomfakes 14y agoI've been meaning to write something like this for the last few months. Rails apps on Heroku need a number of non-default configurations to work well, and this is one of them. Thanks for this - I'll add it to a project this weekend and probably do an updated version of my blog post on this subject: http://blog.craz8.com/articles/2012/12/7/heroku-config-for-performace-rails-apps http://blog.craz8.com/articles/2012/12/7/heroku-config-for-p...