How the Web Works
Posted 2015-03-24 05:00 PM GMT
I love the Web. I have loved the Web for a long time, from online chat rooms and Flash Games in the 90's to Gmail, Facebook, and Wikipedia in the early 2000's to my current role as a professional Web developer. The Web has changed the way we shop, the way we watch TV and movies, the way we work, the way we read the news, the way we socialize, the way we find jobs and show our work experience; in short, the Web has changed the way we live. Considering the fundamental role the web now plays in our lives, I believe we should all have at least a basic understanding of how it works.
The Internet is More Than Just the Web
The Web is a part of the Internet, but there is much more to the Internet, and the Internet is much older. Email, instant messengers, SSH, BitTorrent, and ftp are a few examples of applications of the Internet that are not a part of the Web (or at least they weren't originally).
The Web is a collection of interconnected documents that can be requested using HTTP, and are generally viewed using a Web browser. In recent years, the Web has grown beyond a simple collection of documents to a collection of interconnected applications. Though the terms are sometimes used interchangeably, the Web is not the entire Internet (but it's probably the best part).
What You See
HTML, hyperlinks, and Web Pages
Where it Comes From
Servers, HTTP, and URLs
A server is a computer that stores the HTML documents, ready to be "served" to anyone who asks for them. Requests for Web documents are made over HTTP (Hypertext Transfer Protocol) using URLs (Unifrom Resource Locators). When a server receives a request, it looks for the HTML document associated with the given URL. Modern web servers often create the HTML document as it is requested (e.g. the Facebook feed is different every time you see it, but the URL is the same).There are different types of requests for different purposes. The most commonly used types of requests are GET and POST. An easy way to remember what GET and POST do is to think of a blog.
A GET request is a request to retrieve or "get" some data from the server. When you want to view a blog, you make a GET request.
A post request is used when you want to send or "post" some data to the server. When you want to "post" an entry on your blog, you make a POST request.
How it Gets From Here to There
IP Addresses, DNS, and routing
Every device that is connected to the Internet is assigned an IP address, which is a really big number that identifies the device. (Side note: we made so many Internet connected phones that the really big number wasn't big enough, so we had to switch to IPv6). When you try to go to www.google.com or www.linkedin.com, the Internet doesn't know to which server to send the request, because the Internet only knows about IP addresses, not google.com. When you send your request, the first place the request goes is to a DNS (Domain Name System) which is like a big phone book that maps domains like google.com and linkedin.com to IP addresses like 184.108.40.206 and 220.127.116.11.
Once the IP adress is found, the request bounces through a bunch of routers before finally finding the server. Routers tend to send requests in generally the right geographic direction, depending on a number of factors including other network traffic. Eventually the request will reach the server, and the entire journey usually takes less than 1/10 of a second. The request is sent with a return (IP) address, so the server knows where to send the response.
Browsers Bring it All Together
If you are interested in learning more about the Web, computers, and programming, check out my book, Learning to Program.
- the Web