How Google Suggests Works?
October 9, 2006 Leave a comment
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
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
From Google to Browser
HTTP/1.x 200 OK
Via: 1.0 MSWIPGATE
Date: Tue, 14 Dec 2004 10:13:30 GMT
Content-Type: text/html; charset=utf-8
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.