问题
In production (on Heroku), shouldn't the assets be compiled on bootup one time, and then never compiled again?
/production.rb
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = false
config.assets.digest = true
When someone doesnt hit my application for a while things go idle, and it seems that the assets are re-compiled when that new, fresh request comes in???
Any idea what im doing wrong?
回答1:
On Heroku, if your application is idle for an hour, the dynos will go into standby. That's why when you revisit your application it takes a bit to load the first time. You mention "bootup" time - that's exactly what's happening once your dynos reboot, your instance does not continuously run once you push.
When the dynos are coming back to life, your assets will need to precompile, since you have config.assets.compile
set to false. This behavior really isn't out of the ordinary.
If you want to avoid that, you can set a cron job to curl
your heroku instance every half hour.
来源:https://stackoverflow.com/questions/10871696/why-does-heroku-re-compile-my-assets-after-the-application-has-been-idle-for-a-w