为什么Heroku在应用程序闲置一段时间后重新编译我的资产? [英] Why does Heroku re-compile my assets after the application has been idle for a while?

查看:141
本文介绍了为什么Heroku在应用程序闲置一段时间后重新编译我的资产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在生产(在Heroku上),资产不应该在启动时编译一次,然后再也不会编译了?

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???

任何想法What im im doing wrong?

Any idea what im doing wrong?

推荐答案

在Heroku上,如果您的应用程序闲置一个小时,引擎将进入待机状态。这就是为什么当你重新访问你的应用程序时,第一次加载需要一点时间。您提到启动时间 - 这正是您的dynos重新启动时发生的情况,您的实例在您推送后不会持续运行。

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.

由于你的 config.assets.compile 设置为false,所以你的资源将需要预编译。这种行为真的不是不寻常的。

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.

如果您想避免这种情况,您可以将cron作业设置为 curl 你的英雄实例每半小时一次。

If you want to avoid that, you can set a cron job to curl your heroku instance every half hour.

这篇关于为什么Heroku在应用程序闲置一段时间后重新编译我的资产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆