As we already know, the web is made up of two main parts. The frontend and the backend. The frontend is concerned with presentation and is fairly easy to understand since it is what we interact with daily on the web. The backend, on the other hand, is all of the parts of the web that users do not directly interact with. In this video we are going to discuss the basics of how the backend of a website works by tracing all of the steps that the backend must go through from the moment it receives a request to the point it sends a response back to the client.

Starting at the beginning the server will receive a request from a client in the form of a URL. From this URL the server can get almost all of the information it needs in order to process a request. Let's break apart a typical URL. At the beginning we have the protocol for the request. The only thing that the protocol does is tell the server if the request is encrypted. HTTP is for standard non-encrypted requests, and HTTPS is for encrypted requests. Other than telling the server if the response is encrypted or not the protocol doesn't affect the way the server handles requests and can be ignored. Next, we have the host, also known as the domain name. Again, this is not important to worry about for the server since all it does is tell the internet which server to send the response to. Each server has their own particular host, so once the request actually gets to the server the host does not matter since all requests for the server will have the same host. For example, youtube.com is the host for the YouTube server, so the YouTube server already knows that all requests it gets will have the host youtube.com. This means that we can safely ignore the first half of the URL which leaves us with the last two sections of the URL. The path and the query string. The path tells the server what the client wants and defines which section of code on the server should be run in order to get the correct response. Essentially the server is broken down into a bunch of different sections which all correspond to a specific path. Lastly the query string is used by the specific section of the server to alter the response. The query string is broken down into specific query parameters which can augment the way that the server responds to a request for a specific path. For example YouTube uses the same path when you search for a video, but the query string contains a search_query parameter which tells the server what you searched for so it can respond with what you want.

The URL alone is not enough to tell the server exactly what it needs to do, though. It can tell the server which section to look for and how to alter that section based on the query parameters, but that section of the server is broken down even further into multiple different parts. To determine which part of that section the server should run it needs to use an action which is passed along with the URL. This action can either be GET, POST, PUT, or DELETE. By combining the action and the path the server can find the correct part of the correct section that it needs to run. It can then use the query parameters to alter the response of that particular part and section.

Normally the response from the server will be an HTML page that is dynamically generated based on the request from the client. This is why when you go to the YouTube search page it always shows you the same page, since it has the same path and action, but the videos that are returned from your search are different based on the query parameter for your search.

Another important thing to note about a server is that it is only accessible to the outside world through the sections that it defines. This means that you can store any secure information on the server and it will be safe as long as it is not exposed through a specific path. This is why it is safe to have a database and website running on the same server since the server only chooses to expose the website and not the database. Essentially the server acts as a barrier between the outside world and all the parts of a website.

Next Video:
https://youtu.be/6sUbt-Qp6Pg

Playlist:
https://www.youtube.com/playlist?list=PLZlA0Gpn_vH8jbFkBjOuFjhxANC63OmXM


Twitter:
https://twitter.com/DevSimplified

GitHub:
https://github.com/WebDevSimplified

CodePen:
https://codepen.io/WebDevSimplified


#Backend #WebDevelopment #Programming