How the Web Works: what happens when you type a URL in your browser and press enter

How the Web Works: what happens when you type a URL in your browser and press enter

Mrs Kari is an excellent maths teacher, but she has a weird morning habit, she cannot start her day without seeing a photo of a cute squirrel, so every morning she visits squirrels-under-cover.com to see some squirrelly photos, we don't know the secret behind her love for squirrels, but anyways we'll use her as an example to understand what happens when she types https://www.squirrels-under-cover.com in her browser and presses enter.

All what Mrs Kari sees when she types https://www.squirrels-under-cover.com in her browser is a web page with some cute squirrel photos, but squirrels are not our main concern in this blog post, we're here to understand how the web works so that people can use websites everyday.

So let's first understand what is a URL:

URL stands for Uniform Resource Locator which is simply the address of the server (which is a trained computer responsible for serving the content of the website) in addition to the rules to reach it. And https://www.squirrels-under-cover.com/recent-pages is an example of a URL, so let's break it down:

  1. https specifies the protocol which is the set of rules for communicating over the network, and "https" is a commonly used protocol that helps you send and receive info securely.
  2. www.squirrels-under-cover.com is the domain name, which is the address used to reach the server of this website, you can think of the website as the house and the domain name as the address of this house.
    • Actually, you can replace it with IP address of the server, but since it would be hard to memorize the IP addresses for all the websites you visit, there's a system called Domain Name System (DNS) that helps us map the domain name to its corresponding IP, but that's a topic for another blog, for now it's just enough to know that the domain name and the IP address are interchangeable in the URL.
  3. recent-pages is the path that specifies which part of the house (ie. the website) you will go to, after getting into the house.

What happens when a URL is visited:

Now that we understand what is a URL, let's see what happens when Mrs Kari types the URL of her favorite site and presses enter:

  1. Simply her browser creates a message containing info about the protocol, the host (ie. the server) and some other info.
  2. Then it converts this message into some 0's and 1's, converts them to some signals and sends them to the router.
  3. The router sends them to the correct server.
  4. The server understands those 0's and 1's and sends back the content of the squirrely web page that Mrs Kari wants to see.
  5. The browser understands the content and displays the web page.
  6. Mrs Kari can now start her day.

Conclusion

To conclude what we just learned, we now know the different parts of URL that we need to reach the required website. And we know what happens starting from the moment we type a certain URL in a browser until our browser receives the content of the web page from the server and display it on our screen.

This blog post is a part of a series in which we explore the web in a simple way to understand the concepts that we need to prepare us for becoming awesome web developers. In the next blog posts of this series, we will explore other topics such as DNS, web servers, web protocols, how website content gets displayed, and more.

You can follow us here , so that you don't miss any of our posts.