Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome sends a request multiple times

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)

like image 511
monocle Avatar asked Dec 13 '10 18:12

monocle


2 Answers

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.

like image 170
H_I Avatar answered Nov 08 '22 14:11

H_I


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.

like image 43
Chris Heald Avatar answered Nov 08 '22 14:11

Chris Heald