问题描述
我在 heroku 上有一个 rails 4 应用程序.我对两者都比较陌生.
I have a rails 4 app on heroku. I'm relatively new to both.
我加载的每个页面或执行的 ajax 需要 1 分钟.无论何时总是如此.
Every page I load or ajax I execute takes 1 minute. Always no matter when.
我认为这与 ajax 调用有关,因为我可以直观地看到 DOM 何时完全加载得更好,但它确实是我从 heroku 中抓取的任何页面
I thought it had to do with ajax calls because I an visually see when the DOM is loaded fully better, but it really is any page that I grab from heroku
为了测试这一点,我制作了一个测试页面,其中包含
To test this I made a test page, which consists of
<h2>test</h2>
a test page
没有布局,没有 CSS,没有其他任何东西,没有 html 或 body 标签,只有一个 H2 标签和一些文本,这就是所提供的全部内容.
No layout, No CSS no anything else, no html or body tag, just an H2 tag and some text, thats the entirety of what is served.
所以,在我将 URL 放入浏览器并按 Enter 之后.我看到了 heroku 日志 -t 跳转到生命,我看到了正在处理的请求
So, right after i put the URL in the browser and hit enter. I see the heroku logs -t jump to life and I see the request being processed
2014-07-12T21:07:36.149964+00:00 heroku[router]: at=info method=GET path="/pages/test" host=myapp.herokuapp.com request_id=490be219-e72b-4df3-879b-9060b2b5140a fwd="my.ip.add.ress" dyno=web.1 connect=12 service=11 status=200 bytes=1049
2014-07-12T21:07:36.136011+00:00 app[web.1]: Started GET "/pages/test" for my.ip.add.ress at 2014-07-12 21:07:36 +0000
2014-07-12T21:07:36.141517+00:00 app[web.1]: Rendered pages/test.html.erb (0.4ms)
2014-07-12T21:07:36.139697+00:00 app[web.1]: Processing by PagesController#test as HTML
2014-07-12T21:07:36.141690+00:00 app[web.1]: Completed 200 OK in 2ms (Views: 1.5ms | ActiveRecord: 0.0ms)
到目前为止一切顺利,一切都在 2 毫秒内处理完毕并准备就绪.但是页面没有完全加载.我已经可以看到屏幕上的文字了.但浏览器等待"微调器仍在运行.
All, good so far, everything processed and ready in 2ms. But the page does not load entirely. I can see the text on the screen already. But the browsers "waiting" spinner is still going.
5.32s(加载:1m 5s)
终于加载了.1 分钟后.它对所有页面执行此操作.这确实会影响 AJAX,因为在页面完全加载之前不会发生重绘.
Finally it loads. 1 minute later. It does this with all pages. Which really affects AJAX since the redraws wont happen until the pages is fully loaded.
这是怎么回事,我该如何阻止?谢谢
What is going on and how do I stop it? Thanks
推荐答案
我在 Twitter 上找到了信息.
I found information on Twitter.
这似乎与 websockets 有关.禁用它似乎可以解决问题.
this seems to be related to websockets. Disabling it seems to cure the issues.
heroku labs:disable websockets -a myapp -p production
这使它像以前一样工作,尽管日志现在看起来不同:)
this makes it work as it used to, though the logs now look different :)
编辑:
Heroku 将此显示为解决问题,但如果再次发生,答案适用.
Heroku shows this as a resolve issue, but answer applies in case it happens again.
https://status.heroku.com/incidents/649#update-2163
这篇关于heroku 页面加载缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!