服务资产发展缓慢 [英] Serving assets is very slow in development
问题描述
我有一个standart rails 3 webapp和默认资产管道。突然之间,这些资产花费了很长时间才加载(我的页面加载速度达到〜1-2秒到〜1分钟)。服务器响应时间(/ home)是正常的,但一些.css和.js文件很长时间(最多45秒)处于待处理状态。花费这么长时间的资产只有那些由宝石提供的资产(例如: modernizr-rails / vendor / assets / javascripts / modernizr.js
)
例如,对于 modernizr.js?body = 1
:
请求网址:http://dev.sharewizz.com:3000 / assets / modernizr.js?body = 1
请求方法:GET
状态代码:304未修改
统计信息:
DNS查找5.00 s
连接20.07 s
发送0
等待10 ms
接收3 ms
这是一个链轮问题吗?我怎么知道什么是错的?
注意:所有其他浏览器的行为都是一样的。 编辑:其实问题只在于chrome ,甚至没有safari。
我尝试在端口3000和端口80上使用rails s启动我的服务器(不变)
如果我访问 http:// localhost:3000 / assets / modernizr.js?body = 1
,大部分时间是即时的,有时候会等很长时间。
#扩展加载资源的行
config.assets.debug = false #true
如果您有很多资产,每个人都花时间写入开发日志,总共添加数分钟。
I have a standart rails 3 webapp with the default asset pipeline. All of a sudden, the assets took a very long time to load (my page loads went to ~1-2secs to ~1min). The server response time (/home) is normal, but some .css and .js files are pending for very long (up to 45 seconds). The only few assets that take this long are those provided by gems (eg: modernizr-rails/vendor/assets/javascripts/modernizr.js
)
For example, for modernizr.js?body=1
:
Headers:
Request URL:http://dev.sharewizz.com:3000/assets/modernizr.js?body=1
Request Method:GET
Status Code:304 Not Modified
Stats:
DNS Lookup 5.00 s
Connecting 20.07 s
Sending 0
Waiting 10 ms
Receiving 3 ms
It it a problem with sprockets ? How do I know what's wrong ?
Notes: all other browsers behave the same. Edit: Actually the problem is only with chrome, not even safari.
I've tried to launch my server with rails s on port 3000 and on port 80 (no changes)
If I access http://localhost:3000/assets/modernizr.js?body=1
, most of the times it is instant, sometimes it wait for very long.
Another option - HDD isn't fast enough for logs, just bump into this (suddenly) on my dev pc. Try to set this into config/development.rb:
# Expands the lines which load the assets
config.assets.debug = false #true
If you have a lot of assets, each one take the time to write into dev log, adding up to several minutes total.
这篇关于服务资产发展缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!