问题
I have a rails project. I got very strange thing in one controller: browser needs about 3 minutes for load page but Rails writes in logs:
Completed 200 OK in 20563ms (Views: 17144.2ms | ActiveRecord: 324.4ms)
I know 21 sec it's very long time, but It's not 3 minutes.
I know this data not enough but I don't expect complete answer only a pointer where is trouble. Size of this page about 5 Mb.
回答1:
The delay might be caused by config.assets.debug = true inside of config/environments/development.rb. Setting this to false may resolve your problem.
By doing this,source files are combined together and source maps won't work (e.g. if using Sass/Coffee you won't see it in devtools)
回答2:
As you can see the most of the time is spent in "idle" phase. This includes the time to load all resources on your page (images, stylesheets, javascript, etc.). So, your HTML page is being loaded and rendered in 10 seconds, but the rest is spent to download all the resources in your page.
This can be a single resources that is hosted on some server that is just very slow on responding to your request. So, even if you have a loaded all content, but you have a Google hosted jquery file there and really bad internet connection, then you would see that "idle" to take up a lot of time.
But, in your case, it looks like some images on your 5MB page.
回答3:
I found a problem after long search. It was unnecessary query to database which loaded many related objects for main objects. But I didn't understand why it required such many time (maybe GC clean it mess).
来源:https://stackoverflow.com/questions/37056561/rails-page-loading-very-long-time