Have you ever wondered what exactly happens when you type an URL in the browser and press enter? In this blog, we will see what happens in the background, step by step when we type any URL.
If you want to have a better understanding of this article,then i would recommend you to have an overview of URL and DNS.
1. You enter URL in the browser
It basically means that you want to reach the server where the site is hosted. for example, if you are searching for facebook.com then, you are searching for the server where facebook .com is hosted.
2. The browser looks for the IP Address in the DNS(Domain name server)
a) The browser maintains a cache of the DNS records for some fixed amount of time. So, it is the first place to run a DNS query.
b) If the browser doesn't contain the cache then it requests to the Operating System as the OS also maintains a cache of the DNS records.
c) If your computer doesn't have the cache, then it searches the routers as routers also have the cache of the DNS records.
d) If all above steps fail, the browser would move on to the ISP. Your ISP maintains it's own DNS server which includes a cache of DNS records which the browser would check.
If the requested URL is not in the cache, ISP’s DNS server initiates a DNS query to find the IP address of the server that hosts facebook.com.
The purpose of a DNS query is to search multiple DNS servers on the internet until it finds the correct IP address for the website.
3. The Browser initiates a TCP connection with the server.
When the browser receives the IP address, it will build a connection between the browser and the server using the internet protocol. The most common protocol used is TCP protocol. The connection is established using a three-way handshake.
4. The browser sends an HTTP request to the server.
Once the TCP connection is established, it is time to start transferring data! The browser will send a GET request asking for facebook.com web page.
5. The server handles the request and sends back a response.
The server handles the HTTP request and sends a response. The server response contains the web page you requested as well as the status code, compression type (Content-Encoding), how to cache the page (Cache-Control), any cookies to set, privacy information, etc.
6. The browser displays the HTML content.
At the end, you’ll see facebook.com appearing on your browser.
I really hope that you enjoyed reading this article and learned something from it. If you have any doubt or you think i missed something let me know in the comments.
You can connect with me on:
Top comments (0)