What happens when you click a URL

TUESDAY, SEPTEMBER 22, 2020 12:00 AM    

Have you ever wondered what happens when you actually ‘go to a website’? Do you actually go to a site like how you would imagine going to a physical stall in a mall? In this article, we will be attempting to take away our hats as consumers and address some of these ‘works because it works” assumptions.


  • How does a keyboard work? How does the screen actually know which key was pressed for it the computer operating system to know which letter was entered and to be displayed.
  • How does the OS tell the program something happened? How does it know which program to talk to?
  • How does the browser know to try to load a webpage? I guess it sees an “http://” or just assumes that anything with no prefix is a URL?



So what happens when you load a URL?


#1. Enter a URL onto a Browser


In order for you to load a URL, you need an interface called a client. This client can be your browser. It can also be your terminal. I’ve attached a screen record to show how you are actually accessing a URL using a terminal.



For all our descriptions from here, instead of a browser (which is one of the many clients out there), we will be using a more generic term all client.


#2. Look for DNS to find the associated IP Address


Once you have entered the URL into your client, your client will look out for a IP address based on the domain name.


Given my example, I was entering “https://blog.phuaxueyong.com”. My domain will therefore be “phuaxueyong.com”. It will find the respective Domain name system (DNS) to find the IP address associated to that domain name.


If you want to check out which DNS is any website is using. You can always just type


“whois youtube.com”
“whois <any website you want>”

I’ve also attached a simple screen recording of how it will look like. Cool isn’t it?



#3. Send HTTP request to the server and gets response from server


Imagine this HTTP request to be like a verbal request over the phone.


You: “I would like to take a look at your brochure about your shop”
Shop owner replies: “No problem, here’s the details about my shop”


#4. You will load this response onto your client


All websites are actually just a long file filed with HTML, JS and CSS. Given back the files, you will load that onto your client. On my terminal, i will merely just show me the HTML while a browser will load the HTML as a human readable format.


In these HTML files, there will usually be requests to load other assets. These assets include your images, icons and, annoyingly, your advertisements as well.


5. Continue to load all assets until the page is considered loaded


Once this is done, thats when this ‘magic’ ends. You entered in a URL, and then a page loads. After this article I hope you get to see a glimpse of all the work that takes place behind that URL load.




TLDR;


The ultimate goal of technology is to create such strong resemblance to a real world experience such as going to a stall to visit their site. This strong resemblance creates this resonance within you as if you are actually visiting their site. This is the foundation of all other virtual experiences we are seeking to achieve in the digital era.


A small tip: You want a good technology experience? Mirror this experience to one of reality.




Reference