4

I am using rails 4.2.0 + amazon clodfront + Heroku.

In my config/environments/production.rb i have this config set to true.

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

I frequently asks myself whether this should be set to false or not? As I am confused whether should i manually compile the assets and then push it to heroku, or set it to true?

Please suggest me the best practice.

Sachin Singh
  • 7,107
  • 6
  • 40
  • 80
  • 1
    I think this has been explained here http://stackoverflow.com/questions/8821864/config-assets-compile-true-in-rails-production-why-not – emi Dec 26 '14 at 03:56
  • @siaw23 +1, but i am using amazon cloudfront here, will there be any consequences if i precompile the assets, and push it to heroku and turn off automatic compiling? – Sachin Singh Dec 26 '14 at 08:16

1 Answers1

1

From the perspective of using a CDN like Amazon CloudFront not much. The advantage to setting this to false is that the files are hashed and cached to speed load times. When you migrate your assets to a CDN it handles caching instead of Rails. When the value is set to true the assets do not have the hash which can be useful if you have users requesting assets that are older and may not match the current hash.

eabraham
  • 4,094
  • 1
  • 23
  • 29
  • when this config is set to true on heroku, heroku and i don't precompile the assets, heroku compiles them on its end, does that makes any difference? – Sachin Singh Dec 30 '14 at 10:50
  • If config.action_controller.asset_host is set to your CDN then Heroku does not get involved with serving assets. – eabraham Dec 30 '14 at 17:28