I Wanted To Understand How The Web Works
But by accident I googled ‘How Does The Internet work?” and ended up learning some pretty cool stuff. Blog 1 of 2
It can be hard to admit when we don’t know things, but I think if we can be honest about the gaps in our knowledge, it’s the best opportunity we have to open up and to learn. I’ve found, lately, that when I openly say I don’t understand or I don’t know something, other people around me end up saying that they don’t know either. Last month another junior engineer in search of work mentioned that during an interview he was asked how the web, from a developers standpoint works. He did not do as well as he would have liked with the answer, and I’m telling you right now, my immediate thought was, ‘oh no, I have no idea’. So, here I am, left wondering, ‘What is the web and how does it work?’
If you find yourself in an interview, faced with that same question, and can think of nothing else…best thing to remember is: The web is a series of data exchanges that include requests from clients (aka: browsers) and responses from servers. Yes, it is an extremely surface level response…but it’s better than an ‘I don’t know’. In this blog, I’d like to do a topical overview of the internet and how it’s working around us, then next week we’ll circle back and visit how the web works.
How does the internet work? The easiest way I have learned how to explain this is from a Vox Youtube video you can find here. You can think of your phone or laptop as a ‘radio’. When your phone sends information, it puts your texts, emails, images, url requests, you name it, into an envelope and prepares the envelope in a number of ways. First, any information in this ‘packet’ is sent in binary code (1’s and 0’s) and must be sent in the smallest pieces, so it’s more manageable. Your very intelligent, meme filled ‘radio’ then sends this information through radio waves (unless it’s hard wired) directly to the router. The router, through a hard wired system connected to your Internet Service Provider (ISP), sends the information either through fiber optic filaments (fiberglass) and pulses of lights in code (off representing the 0’s of the binary code, and when the light is on it represents the 1’s), or through copper wires which send the information through pulses of electricity. Your ISP is in charge of connecting your wire through their wires directly to an Internet Hub which in turn connects to the entirety of the network, and includes office buildings, cell providers, homes, and so on. [I love this part of the Vox video, I can’t tell you how many times I have walked by the old Western Union building in NYC and wondered what it looked like on the inside…amazing!]
The information package that has been sent to the Hub in this ‘envelope’ comes along with a number of pieces of information. The information includes headers, which contain code on where it’s from, where it’s going, URL parameters, content type, etc. You should think of headers as ‘content negotiation’¹ It is in this transfer that the URL parameter is split into 3 things as it leaves the browser, the http: or https: is the how or the scheme, the server internet address (www.<address>.com) is the where and the alias of the IP address, and the name of the resource (assets/image.jpeg) is the what and lets the server know what type of information is being requested.
Another part of this transmission involves turning the server internet address back into it’s IP address. This IP address is how the hub will know where to direct the information, to what server. Using this IP address and all of the information on the ‘envelope’ the Internet Hub must determine the most efficient way to get the information to the server. Once the request reaches it’s destination, the 1’s and 0’s are sorted back into full images, and messages. If the information was a request for a url, the server, having read the ‘envelope’ knows that it must resolve the request and respond with information back to the client. This now begins the incredible cycle of the web, and I’ll pick back up here next week in Part 2.
- Fullstack Academy| ‘HTTP Tutorial — How Does HTTP Work’ | https://www.youtube.com/watch?v=M_oTNuVNkms