title: Google.com and clients1.google.com/generate_204
body: <p>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."</p>
  
  <p>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.</p>
  
  <p>I've looked into the JS source code and saw that "generate_204" is requested like this:</p>
  
  <pre><code>(new Image).src="http://clients1.google.com/generate_204"
  </code></pre>
  
  <p>No variable declaration/assignment at all.</p>
  
  <p>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.</p>
  
  <p>Anyone have any ideas as to what the point could be?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>"/generate_204" appears to be available on many google services/servers (e.g., maps.google.com/generate_204, maps.gstatic.com/generate_204, etc...).</p>
  
  <p>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:</p>
  
  <pre><code>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 &lt; l; ++i){
          (new Image).src = two_o_fours[i];
      }
  };
  </code></pre>