How Google Suggests Works?

In Simple words : “Using Ajax”. That’s a lame answer right ?  So what exactly happens underhood of this cool effect in the mighty search engine’s home page? Let’s dig in to the details. (I have posted this on my other weblog almost 2 years back when Web 2.0 was budding up. Sharing the same here again..)

I was totally dragged off from my routine work after tried Google Suggests for the first time. Wondered how it is doing all that so faster way? I Guessed it correctly on RPC calls. A great work on XMLHttp. After a random search, I got gyan on the same from Slashdot.org and Joel On Software.

I found one more interesting analysis on the same here : Auto Complete comes of Age. But out of my curiousity;to dig more through this, I had set up a side bar of Live HTTP Headers for FireFox and observed a very very simple communication between browser and Google. Observe the conversation between my browser and Google.

When I tried my name “Sudhakar Sadasivuni”

From Browser to Google
GET /complete/search?hl=en&js=true&qu=sudhakar%20sadasivuni HTTP/1.1
Host:
www.google.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: PREF=ID=153437983ed96ad9:CR=1:TM=1101787951:LM=1102999867:GM=1:S=OoygLXkhpj3r2pL8
Pragma: no-cache
Cache-Control: no-cache

From Google to Browser
HTTP/1.x 200 OK
Via: 1.0 MSWIPGATE
Content-Length: 105
Date: Tue, 14 Dec 2004 10:13:30 GMT
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Server: Auto-Completion Server
Cache-Control: private, x-gzip-ok=””

The first GET delivers the following RPC command back to browser, which creates a DIV based on the parameters sent in sendRPCDone method.

sendRPCDone(frameElement, “sudhakar sadasivuni”, new Array(“sudhakar sadasivuni”), new Array(“1,480 results”), new Array(“”));

The red marked things are the key players in the “fast” factor of this functionality. Google is using HTTP Compression. It is encoding the content by Gzip algorithm and sending a super compressed packet of Suggestions in the form of a dynamic creation of DIVs on the box.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: