How does the Web work?
The internet is everywhere, or rather, we can access the internet (almost) everywhere. From the small computers we call mobile devices or “phones”, to smart watches, smart TVs, smart refrigerators, smart door alarms, to our laptops, it’s something we take for granted. We click or tap on an icon, type in an address, and will see a website in a matter of seconds, even milliseconds.
While this seems like all there is to it, it’s actually — surprise! — much more complicated. So…how does the internet work?
There’s an important distinction between the internet and the web. GeeksForGeeks distinguishes this by explaining that “the Internet is infrastructure while The Web is service on top of that infrastructure”. So when we talk about ethernet or WiFi, that’s the internet. If we’re talking about online shopping or sharing photos and videos, that’s the Web. So…how does the Web work?
Assuming your WiFi works fine and there are no issues with the Internet, when you go to your Web browser, more likely than not, you’ll type in an address you want to go to. For example, you’re reading this on Medium, so you may have typed in medium.com. After pressing “return” or “enter”, you should see the page of the web address you’re trying to reach.
To begin, your laptop/phone/device is the client. As the client, you’re trying to view a webpage. The webpage is stored in a much larger computer. After all, it’s not the only webpage in that computer, and other people are trying to access that and/or other websites as well. That computer is a server. MDN defines servers as “computers that store webpages, sites, or apps’’.
When you press return or enter, what happens next is the following:
Your device, the client, will look for where the server that hosts that website is located, using DNS. MDN provides an excellent analogy, where this initial check is similar to looking up the location of a shop or restaurant.
Next, it will send an HTTP request to that server that essentially asks, “Do you have space or room for an additional user?” It asks the server to allow the client access to the website. Extending that analogy, it’s similar to seeing if that shop or restaurant has room for you to drop by.
The server will respond with a message: if the server grants the client access, it’ll respond with a 200, or an ok. (“Sure! We have room for one more customer.” in this shop analogy). The client will be able to browse and interact with the website. If the server denies access, then it’ll generate an error, and the client will not see anything.
It’s truly fascinating that this communication between client and server happens in a matter of milliseconds, and how complex the infrastructure that has set up the Internet and the Web is. Please check out the below sources if you’re interested in learning more about the Web itself.
What's difference between The Internet and The Web ? - GeeksforGeeks
What's difference between The Internet and The Web ? Many folks consider that they both are same but are they really…
How the Web works - Learn web development | MDN
How the web works provides a simplified view of what happens when you view a webpage in a web browser on your computer…
HTTP Messages - HTTP | MDN
HTTP messages are how data is exchanged between a server and a client. There are two types of messages: requests sent…