Rails production 模式下,网站打开特别特别慢

zealinux · 2012年09月18日 · 最后由 southwolf 回复于 2012年09月18日 · 3659 次阅读

一开始以为服务器在国外,延时特别大,最后发现在本地测试的时候,也特别慢,没有 5 分钟,下不来。

查看 log/production.log Compiled active_admin.css (4038ms) (pid 3546) Compiled style.css (901ms) (pid 3546) Compiled application.css (915ms) (pid 3546) ...... (tailf 没有显示,奇怪,不一定是 compile 的问题)

问了,为什么要 compile?

不是直接可以推送到浏览器吗

另外,我之前用过 rake RAILS_ENV=production assets:precompile

大家有没有遇到过这种问题?怎么解决

要多些 log

https://gist.github.com/3741071 我贴在这里了。

另外本地首次为什么首次这么慢,能够加速吗

是不是由于找不到一个文件,所以,一直在加载,循环~

Started GET "/homes" for 122.234.244.49 at 2012-09-17 23:22:32 -0400 Processing by HomesController#index as HTML Rendered homes/index.html.erb within layouts/application (26.4ms) Completed 200 OK in 252ms (Views: 125.9ms | ActiveRecord: 1.4ms)

速度正常啊。首次要载入 rails 框架是慢点,不过一般就几秒。5 分钟是别的问题。

Started GET "/assets/front_end/jquery.min.js" for 122.234.244.49 at 2012-09-17 23:22:33 -0400 Served asset /front_end/jquery.min.js - 304 Not Modified (5ms)

不对啊,这些静态文件是要交给 nginx 或者 apache 去处理的,production.log 里应该记录不到这些

#4 楼 @bluebu 估计 LZ 开了这个

# config/environments/production.rb
config.serve_static_assets = true
需要 登录 后方可回复, 如果你还没有账号请 注册新账号