4

Possible Duplicate:
What exactly happens when you browse a website in your browser.

... Describe everything that happens from the time you hit enter, to the time your browser receives a response.

I got this question at an interview today. I don't think I answered it very well. How would you describe what goes on? (in 10 minutes or less).

1

2 Answers 2

5

Roughly,

  1. The browser resolves the URI* to an IP address.
  2. The browser sends a GET request to that IP.
  3. The server finds the correct file.
  4. The server processes the file.
  5. The file is sent to you.

*Uniform Resource Identifier

4
  • How does it resolve the IP address? That's the part that I kinda choked on. It has to query a DNS? Where is the DNS? Does my ISP have a list of DNS providers like GoDaddy and such or what?
    – mpen
    Jan 13, 2010 at 0:40
  • Have you ever check your Network information, your ISP give's you a default DNS server, that you request to resolve the IP adress.
    – Michael B.
    Jan 13, 2010 at 0:42
  • You can also use any DNS you like, you don't have to use the one your ISP provides. OpenDNS is one example.
    – Marcin
    Jan 13, 2010 at 1:06
  • 1
    With 10 minutes, I probably would've gone into more detail with the DNS process. Worst case scenario, you're looking up a root server, then the TLD name server, then the name servers for each subdomain until the entire thing is resolved. I also think it's worth mentioning that if it's an HTML file the browser will do a whole bunch more HTTP GET requests to download image files, client scripts, stylesheets, etc. Finally, the server isn't necessarily serving a static file and can be running scripts are serving cached outputs of previously run scripts, etc.
    – Shane
    Jan 13, 2010 at 2:56
1

You want me to write something that will take about 10 minutes to read?... Does that database support that!?.

... Anyway, for this, you need to understand a few things - in particularly the basics of HTTP protocol and DNS.

Each of these steps is omitting various information as there is just so much I can say, so I will just do the basics - but if you want to know anything in particular, please say and I will try to edit it in.

First things first when you type the address, the browser sets off a DNS query for the address. (This will do a usual lookup - cache, hostfile then server.)

Next, the dns returns the answer and your browser sends of a http request to the ip address of the server, with the host header of the address you are trying to reach and various other headers and information.

The server typically responds with a text stream and your browser displays it.

A good tool to use for diagnosing and experimenting is fetch(on Linux) and WFetch (on Windows).

Alternatively, If you have telnet available (Windows Vista, 2008 and 7 need you to select it) you can do a mock up of a few of the stages by typing the following at the command prompt (or terminal in Linux).

telnet google.com 80

GET /

2
  • HTTP protocol? I s/protocol// ;-) (Or you should have said "DNS system" to be "consistent") Yes, I CNR, S. Jan 13, 2010 at 2:09
  • No, I was just trying to indicate that I wanted a fairly detailed answer in terms of complexity, not a rough overview. Could be in point form :) Anyway.. Yeah, I suck at interviews. Many of these details I knew but neglected to say :\
    – mpen
    Jan 21, 2010 at 2:51

Not the answer you're looking for? Browse other questions tagged .