So you want to visit a webpage eh?
We all know that if you click the little "e" icon on your desktop and type in a string of characters into its address bar, we are magically transported to far off worlds and can research pretty much anything. But how does that address know what to show? and how does your computer know where to get it? And why are cat videos so darn time consuming? Prepare to have all your
burning questions thoughts that popped into your head which you promptly dismissed as not important, answered.
Step 1: The Initial Request.
You stare at the blank screen that lays before you, cursor blinking ever so slowly as if attempting to hold its breath in anticipation of where you are about take it. You begin to type.
w. and pause.
"Why do you type three "w"'s in a row for web addresses?" you think to yourself.
"Not important", as you finish entering the url
A solid choice, sir/madam. Pairs excellently with a glass of
Alright, so you've made your request. The first thing that needs to happen is for your computer to figure out where to go to fetch the website you've just requested. And it does this by using a service.
< queue echo> The Domain Name Service... ervice.... rvice... (Sorry, I'm trying to make this much more exciting than it really is. It's working though, isn't it?)
The Domain Name Service, or DNS for short, is basically a giant registry which converts those easy for humans to read domain names (dogsandcatshugginglikebesties.net) into an Internet Protocol Address (or IP address) When someone registers a domain, they will indicate the IP address of their webserver, and tell that domain to point to that server. Think of an IP address like your home address. Just as your home is assigned a specific house and street number (or name, for those poor people who's municipalities chose names over numbers... I'm sorry) so that mail couriers know where to send your mail to, all computers, web servers included, get assigned an IP address so that network routers know where to send requests to.
So, to recap - You've entered in your domain name, and your request has been fired off through the internet. It knows where to go since the domain name has been converted to the appropriate IP address that points to the correct web server. So what happens when your request gets there? What does the server do?
2. Handling the Request.
At the other end of the request, lies a Web Server. Which, frankly, is just another persons computer. Now, this computer has been specifically built to listen for these incoming requests and depending the type of request, will send back the file that was requested.
dogsandcatshugginglikebesties.net/images/omgsqueeeee.jpg would look inside the
images folder and send back the
omgsqueeeee.jpg image. If just the domain request was sent, it will usually look to send back an
index.php file back to your computer.
The web server could also be running a more sophisticated setup which would funnel every request through a single routing program or file (like that
index.php file) and then use code to determine what to serve back. This bit is where I live in this whole process, so we'll be diving into this stuff in later posts.
At the end of the day, (or any time of the day) the web server will always send back a response when it receives a request. There are a lot of pieces of data that accompany a response back to your computer, two of which are content type and response code. The Content Type tells the browser what type of content is being served back, like a jpg image or an HTML webpage. The Response Code indicates the status of the request, whether the file was not found (404) or if the request triggered a server error (500)
So To recap - The web server has received the request, has figured out what to serve and has sent it back through the internet to your computer with an appropriate content type and response code. Tune in to the next paragraph to find out what your computer does with this response!
3. Your computer displays the response!
shock and awe!
What your browser does with a response depends heavily on the type of content and the response code that was sent back with it. If the content type is an image? well, It will display it! If the content type was a zip file? Download it! Content type is HTML? Render it!
So there you have it. You are now a certifiable expert in how the Internet works. Congratulations! And would you believe I got you here without ever asking for your money. Simply amazing.
a donation would be appre NO! not going there.
sudo apt-get install matchbox-keyboard