What are your favorite websites 2

How the internet works

How the internet works gives a simplified overview of what happens when you visit a website in a web browser on your computer or on your smartphone.

This article is very theoretical and is not essential to start writing code for a website, but after a while you will find that it is beneficial to know what is going on behind the scenes.

Client and server

Computers that are connected via the Internet are called clients or servers. This diagram shows, in a simplified way, how these two computers interact with each other:

  • The computers that are connected to the Internet and are typically used by a user are referred to as clients. For example, your computer that is connected to the network via Wi-Fi, or your smartphone that is connected to a mobile network. The software that visualizes the Internet on the user side, usually web browsers such as Firefox or Chome, is also referred to as the client.
  • Servers are computers that store websites, files or apps. When a client-side computer wants to access a web page, a copy of that web page is downloaded from the server to be displayed in the user's browser.

The other parts of the tool box

The client and the server as described above are not everything. There are other things that are involved in displaying a webpage and we will explain those here.

Try to imagine that the internet is a street. At one end of the street, the client is what your home could be like. At the other end of the street is the server which is like a grocery store where you want to buy something.

On the way from your house to the shop you have to pass a few other places and say hello:

  • Your internet connection: Allows you to send and receive data over the Internet. This is like the actual street you walk to get from your house to the store.
  • TCP / IP: Transmission Control Protocol and Internet Protocol are communication protocols that determine how data is transmitted over the Internet. This is similar to the transport vehicle you use to get to the store, which could be a car or a bicycle or another vehicle.
  • DNS: Domain name servers are like an address book for websites. When you search for an Internet address, the browser looks up the DNS to find the real address of that website. The browser has to find out which server the website is on so that it can send an HTTP request to the right place. This is comparable to looking for the address of the store in which you want to go shopping so that you can find it.
  • HTTP: Hypertext Transfer Protocol is an application protocol which defines a language with which client and server can communicate with each other. This is like the language you use to place your order in the store.
  • Additional files: A website is composed of different files, similar to how you can build something useful out of different parts from the store. These files come in two main types:
    • Code files: Web pages are mostly made up of HTML, CSS, and JavaScript, but there are other options.
    • Content: This is everything else that can be found on a website, such as pictures, music, videos, Word documents or PDFs.

So what exactly is happening now?

When you type an internet address into your browser (like when you go to the store):

  1. The browser contacts the DNS server and finds the real address of the server on which the website is located (you can find the address of the shop).
  2. The browser sends an HTTP request to the server and asks for a copy of the webpage for the client (you go to the store and order your goods). This message and all other data sent between client and server use your internet connection and use TCP / IP for the transmission.
  3. When the server accepts the request, it sends the client a "200 OK" message, which means "Of course you can take a look at the website! Here it is." The server then sends the website files to the browser in small data packets. (You can get your goods in the store and bring them home)
  4. The small data packages are put together in the browser and show you the entire website. (the goods arrive at your home)

DNS explained

Real web addresses are not pretty, easy-to-remember strings that you type into the address bar of your browser to find your favorite web pages. There are special numbers that look like this: 63.245.215.20.

This is an IP address (en-US) and represents a unique address on the Internet. However, this is not so easy to remember. That is why domain name servers were invented. These are special servers that find the correct (IP) address for the address you type in the browser (e.g. "mozilla.org").

Websites can be reached directly via their IP address. Try it: Go to the Mozilla website by entering the following IP address in the address bar of your browser in a new tab:

Data packets explained

Earlier we used the word "data packets" to describe the form in which the data is sent from the server to the client. What do you mean with that? When data is sent over the Internet, it is sent in thousands of tiny bits so that different users of a website can download it at the same time. If web pages were sent in one large package, only one user could download them at a time, which would not make the Internet very efficient.

Read on

Credit