Google.com和clients1.google.com/generate_204 [英] Google.com and clients1.google.com/generate_204

查看:572
本文介绍了Google.com和clients1.google.com/generate_204的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调查google.com在firebug中的网络活动,因为我很好奇并注意到请求正在返回204 No Content。

I was looking into google.com's Net activity in firebug just because I was curious and noticed a request was returning "204 No Content."

事实证明无内容主要用于允许在不对用户代理的活动文档视图进行更改的情况下进行操作的输入,但任何新的或更新的元信息应该应用于当前在用户代理的活动视图中的文档。无论如何。

It turns out that a 204 No Content "is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view." Whatever.

我查看了JS源代码并看到generate_204是这样要求的:

I've looked into the JS source code and saw that "generate_204" is requested like this:

(new Image).src="http://clients1.google.com/generate_204"

根本没有变量声明/赋值。

No variable declaration/assignment at all.

我的第一个想法是它用于跟踪Javascript是否已启用。但无论如何,(新图像).src ='...'调用是从动态加载的外部JS文件调用的,所以这将毫无意义。

My first idea is that it was being used to track if Javascript is enabled. But the "(new Image).src='...'" call is called from a dynamically loaded external JS file anyway, so that would be pointless.

任何人对于这一点有什么想法?

Anyone have any ideas as to what the point could be?

更新

/ generate_204似乎可以在许多谷歌服务/服务器上使用(例如,maps.google.com/generate_204,maps.gstatic.com/generate_204等...)。

"/generate_204" appears to be available on many google services/servers (e.g., maps.google.com/generate_204, maps.gstatic.com/generate_204, etc...).

您可以通过为您的网络应用可能使用的每个Google拥有的服务预先获取generate_204页面来利用此功能。喜欢这个:

You can take advantage of this by pre-fetching the generate_204 pages for each google-owned service your web app may use. Like This:

window.onload = function(){
    var two_o_fours = [
        // google maps domain ...
        "http://maps.google.com/generate_204",

        // google maps images domains ... 
        "http://mt0.google.com/generate_204",
        "http://mt1.google.com/generate_204",
        "http://mt2.google.com/generate_204",
        "http://mt3.google.com/generate_204",

        // you can add your own 204 page for your subdomains too!
        "http://sub.domain.com/generate_204"
    ];
    for(var i = 0, l = two_o_fours.length; i < l; ++i){
        (new Image).src = two_o_fours[i];
    }
};


推荐答案

像Snukker所说,clients1.google.com就在哪里搜索建议来自。我的猜测是,他们会在您需要之前提出强制client1.google.com强制进入您的DNS缓存的请求,这样您在第一次真实请求时的延迟就会减少。

Like Snukker said, clients1.google.com is where the search suggestions come from. My guess is that they make a request to force clients1.google.com into your DNS cache before you need it, so you will have less latency on the first "real" request.

谷歌浏览器已经为页面上的任何链接执行此操作,并且(我认为)在位置栏中键入地址时。这似乎是让所有浏览器都做同样事情的方法。

Google Chrome already does that for any links on a page, and (I think) when you type an address in the location bar. This seems like a way to get all browsers to do the same thing.

这篇关于Google.com和clients1.google.com/generate_204的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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