Thursday, June 23, 2016

What happens when you type "www.google.com" in browser.

1. You enter the URL "www.google.com" in the address bar.

2. Browser tries to resolve the hostname or domain name into IP.

3. First place the computer looks is its local DNS cache, which stores DNS information that the computer has recently retrieved.

4. Ask the recursive DNS server
 - If the records are not present in local DNS cache, your computer queries your ISP's recursive DNS servers.

5. Ask the root DNS server
- If the recursive DNS server does not have record cached, they contact the root name servers.
- The 13 name servers contain pointers for all of the Top-Level Domains (TLDs), such as                        '.com', '.net' and '.org'
- If you enter "www.google.com", the root name servers look at the TLD for the domain -                      www.google.com

6. Ask the TLD DNS servers
- TLD DNS servers look at the next part of the query from right to left - 'www.google.com' -                  then direct the query to the authoritative name servers for 'google.com'.

7. Ask the Authoritative DNS servers
- It will return the IP address of the hostname.

8. The recursive DNS server receives the host record for 'www.google.com' from the authoritative nameservers, and stores the record in its local cache. If anyone else requests the host record for 'www.google.com', the recursive servers will already have the answer, and will not need to go through the lookup process.

Note: If the authoritative name server doesn't recognize the domain, the response indicates failure and the browser generally gives an error like "Can't find the server at www.ppppppp.com

9. After obtaining IP address, web browser opens a TCP connection and then sends the HTTP request, which consist of header and optional content.
- The header includes path requested from server, cache-control etc.

10. HTTP request is sent off to the web server as some number of packets. Each packet has a sequence number that allow them to reassemble together in case packets take different paths.

11. Web server sends the response to the client.

12. Browser checks the response code (200, 201 etc.)

13. If response is cacheable, response is stored in cache.


14. The browser then uses HTML parser to re-create document structure, which is later presented to you on screen. If it finds references to external resources, such as pictures, css files, javascript files, these are is delivered the same way as the HTML document itself.