Ruby on rails 在Heroku上更新到Rails 3.1时的资产管道
我刚刚将我在Heroku上的应用程序从Rails 3.0升级到3.1,我正在努力使资产管道正常工作。主要问题是,我可以从heroku日志中读取每项资产的以下行:Ruby on rails 在Heroku上更新到Rails 3.1时的资产管道,ruby-on-rails,heroku,ruby-on-rails-3.1,web-deployment,Ruby On Rails,Heroku,Ruby On Rails 3.1,Web Deployment,我刚刚将我在Heroku上的应用程序从Rails 3.0升级到3.1,我正在努力使资产管道正常工作。主要问题是,我可以从heroku日志中读取每项资产的以下行: 2011-09-03T16:35:28+00:00 app[web.1]: cache: [GET /assets/border-a3c571a354b9381740db48aeebfaa63a.jpg] miss 如果我正确理解了管道,那么对于我从浏览器发出的每个请求,这不应该是“未命中”,而是应该在缓存中找到 阅读Heroku文档
2011-09-03T16:35:28+00:00 app[web.1]: cache: [GET /assets/border-a3c571a354b9381740db48aeebfaa63a.jpg] miss
如果我正确理解了管道,那么对于我从浏览器发出的每个请求,这不应该是“未命中”,而是应该在缓存中找到
阅读Heroku文档,您可以找到以下解释:
Rails 3.1 provides an assets:precompile rake task to allow the compilation penalty to be paid up front rather than each time the asset is requested. If this task exists in your app we will execute it when you push new code.
但“资产:预编译”任务应该是什么?我尝试从头开始用Rails3.1构建一个项目,试图找出答案,但在一个简单的项目中没有这样的任务。还是我遗漏了什么?如何确保在缓存中找到资产?可能只是配置的问题
以下是我的生产配置文件的选项:
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true # If I turn this off I get a 500 error and logs say that an asset isn't compiled
My application.rb有以下行:
config.assets.enabled = true
非常感谢你的帮助 您能否尝试将
config.service\u static\u assets
设置为true
并
config.action_dispatch.x_sendfile_header = "X-Sendfile"
是否已添加到您的config/environments/production.rb
文件
当您将代码推送到Heroku时,您应该会看到slug编译器AFAICT宣布的预编译。请确保您已启动。那么
注意:我仍然会遇到“缓存未命中”,但我不认为这是真的,因为如果你的资产没有编译,你的应用程序将无法工作。我也在想同样的事情,但这里有一个提示可以帮助你判断你的资产是否是实时编译的
- heroku博士
- 在heroku上安装memcached
- 赫罗库医生
“------>为Rails资产管道准备应用程序”出现,但之前也出现过。但仍在获取缓存未命中…它不应该使用ngnix指令吗
config.action\u dispatch.x\u sendfile\u header='x-Accel-Redirect'
yes,我有Cedar堆栈。如果激活了“实时编译”,则每次缓存未命中时,它都会对其进行编译。实际上,如果我停用此选项(使用'config.assets.compile=true'),则它根本不起作用。我直接在heroku上编译资产,而不会用编译的资产污染本地存储库。使用命令:heroku run rake assets:precompile