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];
}
};
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.
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.
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
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 is using this to detect whether the device is online or in captive portal.
Here is the relevant explanation from the Google Chrome Privacy Whitepaper:
More info: http://www.chromium.org/chromium-os/chromiumos-design-docs/network-portal-detection