Google.com and clients1.google.com/generate_204
Asked Answered
R

11

49

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.

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.

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?

UPDATE

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

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];
    }
};
Reganregard answered 1/1, 2010 at 18:18 Comment(3)
well, why create empty image offline, if we can get one online from google? :)Sadi
Maybe the external JS file is used somewhere else not dynamically? I don't really know, seems to have something to do with debugging and/or proxies?Positron
@mykhal: What? @Positron Muyser: I doubt the JS is used elsewhere, and if it was - detecting if JS was enabled would happen when the file was requested.Reganregard
O
28

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.

Outandout answered 1/1, 2010 at 19:21 Comment(5)
Great answer! I'll probably end up marking this as correct if no-one comes by with an official answer soon. Now I've got to try to find a useful way of using it! THANKS!Reganregard
i don't think it makes any sense :)Sadi
My browser automatically opens gstatic.com/generate_204 when I'm browsing. Doesn't really seem like the same scenario here?Pamella
It's to test if you actually have an internet connection. When you are on a wifi accessing any webpage might still generate a 200 ok response but show you a different webpage to the one you created. Google tests this by trying to get a url that will generate a 204 and if that succeeds they know you are actually online (rather than on a broken hotspot)Mcgruter
@DavidMurdoch Read the other answer too. They refer official source.Merciful
D
36

I found this old Thread while google'ing for generate_204 as Android seems to use this to determine if the wlan is open (response 204 is received) closed (no response at all) or blocked (redirect to captive portal is present). In that case a notification is shown that a log-in to WiFi is required...enter image description here

Detach answered 13/11, 2012 at 17:42 Comment(5)
How do they know this is happening on Android. Is the traffic being sniffed. Do you have a source. But that's cool to use a low overhead method here. No chainsaw fly swatters.Maladapted
Agreed - seen this behaviour on android and desktop Chrome. The generate_204 address can be seen in the address bar when responding to the 'Log in to WiFi network required' prompt.Tufts
I got this error when I was playing around with Hotspotsystem and was using Android phone.Reply
I came across the 'generate 204' when I was logging into a hotel Wifi. The wifi was unsecured, but required a username and password through a hotel website that only appeared when I first tried to navigate to a page. Chrome threw a clients3.google.com/generate_204 to bring up the hotel website that allowed me to log in. I've since seen this many times (mostly on my Android when using Chrome) when there is no WPA, but there is an authentication process.Gerent
In AOSP source code, this is defined in frameworks/base/services/core/java/com/android/server/ConnectivityService.javaKeverne
O
28

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.

Outandout answered 1/1, 2010 at 19:21 Comment(5)
Great answer! I'll probably end up marking this as correct if no-one comes by with an official answer soon. Now I've got to try to find a useful way of using it! THANKS!Reganregard
i don't think it makes any sense :)Sadi
My browser automatically opens gstatic.com/generate_204 when I'm browsing. Doesn't really seem like the same scenario here?Pamella
It's to test if you actually have an internet connection. When you are on a wifi accessing any webpage might still generate a 200 ok response but show you a different webpage to the one you created. Google tests this by trying to get a url that will generate a 204 and if that succeeds they know you are actually online (rather than on a broken hotspot)Mcgruter
@DavidMurdoch Read the other answer too. They refer official source.Merciful
D
20

In the event that Chrome detects SSL connection timeouts, certificate errors, or other network issues that might be caused by a captive portal (a hotel's WiFi network, for instance), Chrome will make a cookieless request to http://www.gstatic.com/generate_204 and check the response code. If that request is redirected, Chrome will open the redirect target in a new tab on the assumption that it's a login page. Requests to the captive portal detection page are not logged.

Source: Google Chrome Privacy Whitepaper

Dunt answered 28/10, 2013 at 2:25 Comment(0)
B
12

Google is using this to detect whether the device is online or in captive portal.

Shill, the connection manager for Chromium OS, attempts to detect services that are within a captive portal whenever a service transitions to the ready state. This determination of being in a captive portal or being online is done by attempting to retrieve the webpage http://clients3.google.com/generate_204. This well known URL is known to return an empty page with an HTTP status 204. If for any reason the web page is not returned, or an HTTP response other than 204 is received, then shill marks the service as being in the portal state.

Here is the relevant explanation from the Google Chrome Privacy Whitepaper:

In the event that Chrome detects SSL connection timeouts, certificate errors, or other network issues that might be caused by a captive portal (a hotel's WiFi network, for instance), Chrome will make a cookieless request to http://www.gstatic.com/generate_204 and check the response code. If that request is redirected, Chrome will open the redirect target in a new tab on the assumption that it's a login page. Requests to the captive portal detection page are not logged.

More info: http://www.chromium.org/chromium-os/chromiumos-design-docs/network-portal-detection

Boatright answered 10/6, 2014 at 4:20 Comment(1)
The related source code is found here cs.chromium.org/search/?q=kRestrictiveProxyURL&type=csCacoepy
S
5

204 responses are sometimes used in AJAX to track clicks and page activity. In this case, the only information being passed to the server in the get request is a cookie and not specific information in request parameters, so this doesn't seem to be the case here.

It seems that clients1.google.com is the server behind google search suggestions. When you visit http://www.google.com, the cookie is passed to http://clients1.google.com/generate_204. Perhaps this is to start up some kind of session on the server? Whatever the use, I doubt it's a very standard use.

Sterne answered 1/1, 2010 at 19:9 Comment(1)
By the way, try clicking "I'm feeling lucky" when the search box is empty. If you do this on new year's day, you may get a surpriseSterne
O
5

with the massive remit by google to stop both spam and the scraping of their search database, I believe that this is part of the effort to track bots etc.

some simple anti bot pseudo could go like this.

On GET (google.*) Save RemoteEndPoint
{
    If RemoteEndPoint GETs (clients1.google.com/generate_204) Then
        Set botAlert_stage1 = false;
    Else
        Set botAlert_stage1 = true;
    End If
}

I also believe that the latest google frontpage 'theme' is also a new tool to help with the anti spam/bot activity.

** NOTE ** ipv6.google.com also includes this measure.

Just my unfounded unproofed two 2p.

Outshoot answered 7/1, 2010 at 12:47 Comment(1)
why downvote? he's got a valid point. speculation, but that's all we can do since we can't reliably know what Google uses their 204's for.Py
P
4

Many applications access this URL to determine if they have a connection that only leads to a captive portal.

The idea is that any captive portal thinks this is a "normal" website, and then redirects you to its portal site, which is returned with a status 200. If an application tries to access any normal website, it is confronted with a totally unexpected response and may have problems figuring out what's wrong. However, with this URL it's easy: If you get status 200, you are inside a captive portal, and you can tell your user to do something about it (usually either log in to the portal using a browser, or turn WiFi off and rely on 3G, if they are using a phone). If you get status 204, you got connected to Google, so your application is actually connected to the internet.

Microsoft and Apple use a slightly different approach; they both have some URLs that return a very specific short text message with a status 200, so instead of accessing the Google url you can for example go to "captive.apple.com" and check for status 200 with data = "Success" and nothing else. If you get status 200 and not exactly that data then you are again in a captive portal.

Platon answered 6/6, 2016 at 9:0 Comment(0)
D
3

This documents explains:

http://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1417&context=ecetr&sei-redir=1

(Search for generate204)

Relevant section:

Among the different objects, a javascript function triggers a generate204 request sent to the video server that is supposed to serve the video. This starts the video prefetch, which has two main goals: first, it forces the client to perform the DNS resolution of the video server name. Second, it forces the client to open a TCP connection toward the video server. Both help to speed-up the video download phase.

In addition, the generate204 request has exactly the same format and options of the real video download request, so that the video server is eventually warned that a client will possibly download that video very soon. Note that the video server replies with a 204 No Content response, as implied by the command, and no video content is downloaded so far.

Diminuendo answered 14/2, 2012 at 21:32 Comment(0)
L
2

I found this blog post which explains that it's used to record clicks. Without official word from Google it could be used any number of things.

http://mark.koli.ch/2009/03/howto-configure-apache-to-return-a-http-204-no-content-for-ajax.html

Linzer answered 1/1, 2010 at 19:45 Comment(1)
The google.com/csi URL returns 204, and seems to be used for tracking. But I don't think it has any connection to generate_204 (the URL the question asks about)Sargasso
F
0

The generate 204 might be dynamically loading the suggestions of search criteria. AS i can see from my load test script, this is seemingly responsible for every server call each time the user types into the text box

Foggy answered 27/7, 2010 at 7:34 Comment(0)
S
-1

Well i have been looking at this for a few times and resulted that Google logs referer's where they come from first time visiting the google.com for ex; tracking with Google Chrome i have a 90% guess that its for Logging Referers, maybe User-Agent statistics well known when Google release its list of standards of browser usage:

Response Headers

  • Content-Length: 0
  • Content-Type: text/html
  • Date: Fri, 21 May 2010 17:06:24 GMT
  • Server: GFE/2.0

Here "Referer" under "^Request Headers" shows Googles statistics that many folks come from Microsoft.com, also parsing out the word "Windows 7" to help me focus on Windows 7 in my up-following searches that session

//Steven

Ss answered 21/5, 2010 at 17:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.