Chrome多次发送请求 [英] Chrome sends a request multiple times

查看:428
本文介绍了Chrome多次发送请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails 3应用程序,并且注意到当使用Chrome(在Mac上)访问应用程序时,网站上的每个页面都被请求两次。这在开发和生产(Heroku)中发生。 Firefox和Safari只发送一次请求。即使我删除操作的所有布局和内容,行为也是一样的。似乎有一个MIME类型的问题。有没有人解决了这个问题?

  class PagesController< ApplicationController 
def home
render:text => 'a',:layout => false
end

这是开发中的服务器日志:


在2010年12月13日星期一10:33:33 -0800开始GET/为127.0.0.1



通过PagesController#home处理 HTML



渲染文本模板(0.0ms)

<






在2ms内完成200 OK(查看:1.3ms | ActiveRecord:0.8ms) blockquote>

在2010年12月13日星期一10:33:33 -0800开始GET/为127.0.0.1



处理PagesController#home作为* / *



渲染文本模板(0.0ms)

在3ms中完成200 OK(查看:1.7 ms | ActiveRecord:1.4ms)


解决方案

我发现了什么导致了我的问题, :我使用了Google Chrome的扩展名Web服务器通知程序 Web技术通知程序,它们提出了自己的请求。

取消激活后,每页只有一个请求。


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)

解决方案

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.

这篇关于Chrome多次发送请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆