What happens when you type www.amazon.com or any URL in browser?

1. you type www.amazon.com into the address bar or the browser

2. Your browser checks the cache for a DNS record to find the corresponding ip address.
DNS is a database that maintains a list of website URL and their corresponding ip address it links to.

In order to find the DNS record, the browser checks four caches:

2.1 Browser cache : browser maintains the list of dns records for a fixed duration for websites you have previously visited

2.2 OS Cache: after browser it asks the OS cache for the dns record, by making a call to OS, (gethostname on windows)

2.3 Router cache: browser then communicates with the router to get the dns record

2.4 ISP Cache:

3. ISPs DNS server initiates a DNS query to find the IP address of the server that hosts amazon.com
The purpose of the DNS query is to search multiple DNS server until it finds the correct IP address of the website. This type of search is called recursive search.
 ISPs DNS server is called DNS recursor, whose main job is to find the correct IP address of the URL.
Root Domain = .
Top Level Domain = com, org
second level domain = amazon, google
third level domain = www, download,….

4. Browser initiates a TCP connection with the server
Most common protocol used by browser is TCP. Most of the HTTP connection are made using TCP.
It establishes a three way handshake.

4.1 Client sends a SYN packet to the server over the internet, asking if it is free for connection.

4.2 If the server has open ports that can accept new connection, then it will respond with ACK of the SYN packet, with SYN/ACK

4.3 The client will respond to the SYN/ACK packet by sending a ACK to the server.

Then a TCP connection is established for data transmission.

5. The browser sends an HTTP request to the web server.
The browser now sends a GET or POST request to the webserver, asking for the data or posting the form data respectively.
User-Agent header: info about browser
Accept Header: types of request it will accept
connection: keep the connection alive
Will also pass the cookie information

6. The server handles the request and sends back the response
The server contains a web server, which passes the request to the request handler to generate the response. The request handler is a program which reads the request and generates the response accordingly.

7. The server sends out an HTTP response
The server send out the response, along with status code, compression types (Content-encoding), how to cache the page (Cache-Control).any cookies to set, privacy information, etc.

HTTP Status Codes:

1xx – Informational Message only
2xx – Success messages
3xx – Redirects the client to another URL
4xx – error on the client’s part
5xx – error on the server’s part

8. Browser displays the HTML content

About the author
Kunal Choudhary

Leave a Comment

Contact About