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

Understanding how your browser works

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

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:-

  1. The browser looks up its cache to see if that website was visited before and if the IP address is known.

  2. If it can't find the IP address it asks your operating system to locate the website.

  3. The Operating System searches for the IP address in the host file.

  4. If it does not find it inside this file, it will make a DNS request to find the IP Address of the webpage.

  5. First, it asks the ISP (Resolver) server to look up its cache to see if the IP Address is known.

  6. 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).

  7. 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?

  8. Now the OS has the IP Address, it gives it to the browser and makes a GET request to the IP Address.

  9. 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.

  10. To ensure no security violations it is checked by the firewall and the OS and the server.

  11. After receiving the request, the server sends a response with the IP Address along with an SSL certificate to ensure a secure connection (HTTPS)

  12. Lastly, the server sends the HTML, CSS and JAVASCRIPT files back to the OS, which gives it to the browser to interpret it.

  13. 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