What happens when you type "www.google.com" in your browser
Understanding how your browser works
Table of contents
Introduction
The Internet is the developer's best friend, and the platform where they interact is a web browser. Any error we encounter makes us go to our favorite browser and search the internet for it. (seems the internet is Doraemon for we Noobitas, sorry for this weird analogy but I couldn't stop myself from writing it)
So have you ever wondered, what exactly happens when you hit the search button?
No worries, you will know by the end of this article.
(P.s. - It is a popular interview question too)
What Happens .......
When you search for any URL in the browser, the following things happen:-
The browser looks up its cache to see if that website was visited before and if the IP address is known.
If it can't find the IP address it asks your operating system to locate the website.
The Operating System searches for the IP address in the host file.
If it does not find it inside this file, it will make a DNS request to find the IP Address of the webpage.
First, it asks the ISP (Resolver) server to look up its cache to see if the IP Address is known.
If the IP Address is not known by the Resolver, it then asks the root server to ask the .com TLD server (.com because here the URL ends with .com).
The TLD server will check its cache to see if the requested IP Address is there, if not then it will have at least one of the authoritative name servers associated with the URL, after going to the Name Server it will return the required IP Address. phew tiring for a human, isn't it?
Now the OS has the IP Address, it gives it to the browser and makes a GET request to the IP Address.
When the request is made, the browser again makes the request to the OS, which packs the request in TCP protocol, and it is sent to the IP Address.
To ensure no security violations it is checked by the firewall and the OS and the server.
After receiving the request, the server sends a response with the IP Address along with an SSL certificate to ensure a secure connection (HTTPS)
Lastly, the server sends the HTML, CSS and JAVASCRIPT files back to the OS, which gives it to the browser to interpret it.
Now we get the desired website. Yyyayyyy !!
Additional Resources
Cache -> pronounced as 'cash', is used to store temporary files using hardware and software components.
TCP -> Transmission Control Protocol is a communications standard that enables application programs and computing devices to exchange messages over a network. It is designed to send packets across the internet and ensure the successful delivery of data and messages over networks.
packet -> small segment of a larger message