渲染视图花费的时间太长

发布于 2024-12-04 22:23:50 字数 583 浏览 2 评论 0原文

我看了类似的问题,但似乎没有相关的解决方案。

我目前正在使用新的 MBP(从 PC 转换而来),所以我假设这不是硬件问题,因为我渲染的都是静态页面。

在 PC 上运行完全相同的配置,一切似乎都很好:

RVM 1.8.1

Ruby 1.8.7

Rails 3.0.3

Webrick 1.3.1

缓存并不能真正解决问题,因为我正在设计,因此需要不断重新加载。

Started GET "/" for 127.0.0.1 at Thu Sep 15 02:06:50 -0400 2011
  Processing by PagesController#home as */*
Rendered pages/home.html.erb within layouts/application (7.5ms)
Completed 200 OK in 24114ms (Views: 24113.6ms | ActiveRecord: 0.0ms)

这种情况经常发生,有时服务器显示较低的渲染时间,但浏览器中的页面不会再刷新 10 秒。

任何帮助将不胜感激。

I looked as similar questions, but there doesn't seem to be a related solution.

I'm currently using a new MBP(transitioned from a PC), so I'm assuming its not a hardware issue since all I`m rendering is static pages.

With the exact same configuration running on a PC everything seemed fine:

RVM 1.8.1

Ruby 1.8.7

Rails 3.0.3

Webrick 1.3.1

Cacheing doesn't really solve the problem since I'm working on design, thus need constant reloads.

Started GET "/" for 127.0.0.1 at Thu Sep 15 02:06:50 -0400 2011
  Processing by PagesController#home as */*
Rendered pages/home.html.erb within layouts/application (7.5ms)
Completed 200 OK in 24114ms (Views: 24113.6ms | ActiveRecord: 0.0ms)

This happens quite often, sometimes the severs shows lower rendering times but it doesn't refresh the page in the browser for another 10x seconds.

Any help would be deeply appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浊酒尽余欢 2024-12-11 22:23:50

我不确定这是否可以解释在 Windows 和 Mac 上运行之间的差异(我想它们是相同的),但是这可能是您的环境在开发模式下为每个请求重新加载的事实吗?

在较大的代码库上,我遇到了加载缓慢的问题,并且 rails_development_boost 创造了奇迹。它基本上会缓存您的类,但会监视 FS 文件的更改并在运行时重新加载它们(您不必不断停止/启动服务器)。

在您的 Gemfile 中

group :development do 
  gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git', :require => 'rails_development_boost'
end

如果这没有帮助,您能否发布一些可能在 pages/home.html.erb 文件中发生的迭代示例来解释慢下来了吗?

I'm not sure if this would explain differences between running on windows and mac (i'd imagine they'd be the same), but could it be the fact that your environment is being reloaded for each request in development mode?

On larger code bases, I've had this problem with slow loading and rails_development_boost works wonders. It basically caches your classes, but monitors the FS for changes to files and reloads them at runtime (you don't have to stop/start server constantly).

In your Gemfile

group :development do 
  gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git', :require => 'rails_development_boost'
end

If that doesn't help, can you post some examples of any iteration that may be taking place in the pages/home.html.erb file that could explain the slow down?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文