DEV Community

shaddu
shaddu

Posted on

What is Backend? Quick Read

The server will receive a request from the client in the form of a URL. From this URL the server can get almost all the information.

http://example.com/path?query=value

Let us break a typical url :

Protocol -> http://
The protocol tells the server whether the request is encrypted or not. HTTP is for standard non encrypted requests and HTTPS is for encrypted requests. Other than telling the server if the request is encrypted or not, the protocol does not affect how the server handles the request.

Host or Domain Name -> example.com
It tells the internet which server to send the response to. Each server has its own particular host name example youtube.com or netflix.com
Once the request actually gets to the server, the host name does not matter since all request to that server will have the same host name because it was directed toward that server(duh🥹).

This means we can safely ignore the first half of the URL. This leaves us with path and query strings.

Path -> /users, /cats, /dogs
Tells the server what the client wants and finds which code on server should be run in order to get the correct response.

Query String -> https://www.youtube.com/results?search_query=cats
It 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 the server responds to your request for a specific path.

The URL alone is not enough to tell the server exactly what it needs to do with the request. It can tell the server which section to look for and how to alter that section based on query parameters but that section of the server is broken down even further into multiple different parts.

To determine which part of the section the server should run it also needs to use an action which is passed along with the URL.

Most commonly used actions are:

  • GET -> Read data from web server
  • PUT -> Modify data on the server
  • POST -> Send data to the server
  • PATCH -> Similar to PUT, only difference, modifies a part of data
  • DELETE -> Delete data on server

Combining the action and the path, the server can determine part of the correct section that it needs to run. It can then use the query parameters to alter the response of that particular path and section.

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

The server is only accessible to the outside world through the sections or paths it defines example /users, /cats, /search. This means you can store any secure information on the server as long as it is not exposed through a specific path. That is why it is safe to have a database and a 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 our website.

Top comments (0)