Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用Ruby 2.3.3-p222缓慢加载Rails 5.1.4_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 使用Ruby 2.3.3-p222缓慢加载Rails 5.1.4

Ruby on rails 使用Ruby 2.3.3-p222缓慢加载Rails 5.1.4,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 4,我有一个数据库查询MySQL的标准视图。我正在使用Desive and method检查it用户是否登录layouts/application.html.erb: 布局包括4个部分_header.html.erb和_footer.html.erb。从HTML标记到HTML生成的所有HTML大约有320行 在生产中,我设置: config.assets.raise\u runtime\u errors=false 网站加载速度非常慢,但只是第一次,在启动服务器之后,加载哪个页面并不重要。这对所有人

我有一个数据库查询MySQL的标准视图。我正在使用Desive and method检查it用户是否登录layouts/application.html.erb:

布局包括4个部分_header.html.erb和_footer.html.erb。从HTML标记到HTML生成的所有HTML大约有320行

在生产中,我设置: config.assets.raise\u runtime\u errors=false

网站加载速度非常慢,但只是第一次,在启动服务器之后,加载哪个页面并不重要。这对所有人都是一样的。若我再次加载页面停止并启动服务器并重新加载页面,那个么速度会很慢,但在服务器启动后第一次加载之后,它会正常加载页面

生产中:

加载20毫秒; 8毫秒的CSS文件, JS文件-14毫秒和三个图像,每个大约10-20毫秒。 11Kb的页面加载时间超过9秒

在开发过程中,在同一个页面上,我对9个CSS/JS/img文件有不同的请求,每个文件的加载时间在20-50ms之间,同一个页面的加载时间在11秒以上,为11.4Kb

当它处于开发模式时,我在控制台中读到:

2017年10月12日23:33:48+0300开始获取127.0.0.1的联系人

1.0ms SET@@SESSION.sql\u mode=CONCATCONCAT@sql\u mode',STRICT\u ALL\u TABLES',',,NO\u AUTO\u VALUE\u ON\u ZERO',@@SESSION.sql\u AUTO\u is\u null=0,@@SESSION.wait\u timeout=2147483

1.0ms从schema_migrations按schema_migrations.version ASC排序的schema_migrations.version中选择schema_migrations.version

ContactsControllerindex作为HTML进行处理

在布局/应用程序中呈现index.html.erb

布局/应用程序1.0ms内呈现的index.html.erb

渲染部分/u header.html.erb 1.0ms

渲染部分/_footer.html.erb 0.0ms

呈现部分/u login\u modal.html.erb 1.0ms

渲染部分/_注册_modal.html.erb 0.0ms


我使用的是Windows10,但在Ubuntu上也是如此。如果我将站点上传到Heroku,并且只有在浏览器第一次加载站点时,情况也是一样的。

Rails会在第一次请求时在缓存浏览器中加载所有Javascript和CSS。在它使用什么来模拟一个单页应用程序之后

这就是为什么您的第一个请求很慢,而不是其他请求。这是rails团队做出的实现选择


但在你的情况下,9秒和11秒真的很慢。我可以在Heroku上找到你网站的链接吗?

嗨,我不能提供我的应用程序,但我做了测试,我发现它不仅仅是我的。例如,我创建了一个新的应用程序。默认情况下,该页面正常加载约1秒,但我使用方法索引和空视图索引创建控制器测试,再次加载约7-10秒,服务器启动后,我正在使用heroku重新启动服务器-重新启动我的应用程序。你可以在这里查一下-
<% unless user_signed_in? %>
    <%= render 'partials/login_modal' %>
    <%= render 'partials/registration_modal' %>
<% end %>