Reputation: 5896
I have a Rails 3 app and just noticed that when using Chrome (on Mac) to access the app, every page on the site is being requested twice. This is happening in development and production (Heroku). Firefox and Safari only send the request once. The behavior is the same even when I remove all layouts and content for the action. It seems like there's a MIME type issue. Has anyone fixed this problem?
class PagesController < ApplicationController
def home
render :text => 'a', :layout => false
end
This is the server log in development:
Started GET "/" for 127.0.0.1 at Mon Dec 13 10:33:33 -0800 2010
Processing by PagesController#home as HTML
Rendered text template (0.0ms)
Completed 200 OK in 2ms (Views: 1.3ms | ActiveRecord: 0.8ms)
Started GET "/" for 127.0.0.1 at Mon Dec 13 10:33:33 -0800 2010
Processing by PagesController#home as */*
Rendered text template (0.0ms)
Completed 200 OK in 3ms (Views: 1.7ms | ActiveRecord: 1.4ms)
Upvotes: 11
Views: 7334
Reputation: 411
No, but I haven't been bothered by it. TBH I had totally forgotten about this post.
Upvotes: 0
Reputation: 797
I found this thread while researching a similar issue.
I have an HTML <OBJECT>
whose data is being populated by a call to a php script. I am getting two calls (GET) to the PHP script when running in Chrome 27.0.1453.81, but only one from IE (10.0) or FF (19.0.2). Looking at the HTTP traffic, the second GET is being generated after the first GET, but before the first GET responded, so I'm inclined to agree with the suggestion that Chrome is being impatient and sending the second GET when it believes the first one has failed (which it hasn't).
My php script will always take a couple of seconds to run and I can't work around that, and this second call is causing me some grief, so I'm interested in any strategy that might control it.
Upvotes: 0
Reputation: 385
I found what caused my problem, and maybe yours: I used Google Chrome's extensions named Web Server Notifier and Web Technology Notifier which made their own request.
After deactivating them, I got only one request per page.
Upvotes: 7
Reputation: 62668
The problem may be related to this issue: http://news.ycombinator.com/item?id=1872177
Chrome is trying some aggressive tactics in its developer builds (I think that is cool). What they're doing is speculatively opening sockets to servers, and also opening a second socket if their first attempt doesn't get a response quickly enough. It's pretty easy to see how a bug in this stuff, or even just the expected behavior, could trigger abuse filters. But, as I said, I think it is worth doing. All these web startups will make more money if the Web is faster.
If your Rails app isn't responding quickly enough, it's possible that Chrome is attempting alternate ways of getting content back for the user; there may not be much you can do about it. Your response times are very fast, but depending on the spin-up time of the connection, that might be a part of the issue.
Upvotes: 5