What happens when you type a URL into your browser?

May 7, 2023·

5 min read

Everyone who is using the internet uses a web browser on a daily basis from studying how quantum computers work to learning how to make biryani, and each such search result takes a few seconds to load.

Have you ever wondered what goes on behind the scenes? Let us have a basic understanding of how the web browser works.

To really grasp what happens when you type a URL into your search box, you must first understand a few characters in our story. What exactly is a website? What exactly is a URL? What exactly is a server? What exactly is an IP address? And what exactly is a DNS?

What is a Website?

MacBook Pro on top of brown wooden table during daytime

A website is a collection of HTML, CSS, and JavaScript files.

It's essentially lines of code written on these files that, when compiled together, give you the full layout of the page you're looking at, including the text, photos, video, and so on.

So it's simply just a collection of files. These files must be saved somewhere, they can't be stored on your own computer or laptop since then your friend or someone else will be unable to access these files, which brings us to the concept of what is known as a server.

What is a Server?

building photography

In a nutshell, it's an extremely powerful computer where these files will be stored, and its major function is to store these files and give them whenever your browser requests them. So that's a basic definition of a server.

So, how do the browser and server communicate with one another?

When you input the URL, your browser must communicate with that server and retrieve these files in order to show the website to you. If you think about it, there are a few questions you must answer here. How does the browser translate that URL, which is most likely only in English, to something that the server can understand? And how does it know which server to use to retrieve these files? Because, if you think about it, not all of the world's websites, nor all of the world's website files, could conceivably be stored on a single computer. There might be millions upon millions of such servers.

So, how does the browser determine which server to visit and pass this information from? To answer this, let's dive into the different sections of the URL itself.

What is a URL?

a computer screen with a remote control on it

As an example, suppose you want to navigate to https://docs.google.com. The first portion, "https://," basically tells the browser what type of connection to create with the server. You don't need to be concerned about what "https" truly means, but you may grasp that https fundamentally indicates that your connection will be more secure.

The second piece, which is "docs.google.com," is essentially what is called the domain name. Now, the domain name is essentially going to be mapped to something called an IP address. The IP address is a bunch of numbers separated by dots, which will look something like this: Each unique domain name will have a unique IP address associated with it. Now, the IP address you can understand to be something very similar to your house address. If you don't know the IP address of, say, your server or your domain, then you're not going to really know where to reach out to in order to fetch those saved files.

Putting everything we've spoken about together,

Step one: is to type the URL into your browser. Step two: the browser obtains the server's IP address based on your domain name. Step three: involves the browser establishing a connection with that specific server. In Step four: the browser sends a request to the server for the files. Step five: the server analyses the request and responds with the files. The browser then renders the content on the screen, which you can then see as your web page in step six.

What is meant by a DNS?

One point we didn't cover here is how the browser determines where to look to find this specific IP address for this specific domain name. Now, there is this concept known as a Domain Name System or DNS for short. The DNS is similar to a contacts app on your phone or a phone book in that it records each domain name as well as the IP address for that specific domain name.

If you've seen, each request that you place, each URL that you write, the response is coming back in roughly one to three seconds. As a result, determining the IP address for that specific site must be lightning-quick. As a result, the DNS is typically kept or cached in numerous locations. You don't need to know much about what a cache is, but simply know that it's a type of storage that is closer to the browser and also speedier for any retrieval actions that you want to execute.

The browser essentially, as soon as it gets the domain name, it searches the DNS, the different DNSs that are stored in different places for the IP address. Once it gets the IP address, then it performs the rest of the steps that we see here.

That is essentially what happens when you type a URL into your browser. So, I hope this was useful.

Did you find this article valuable?

Support Ashwin B by becoming a sponsor. Any amount is appreciated!