The Evolution of HTTP

Tram Ho

Hello friends.

When you are familiar with web programming or working in the IT field, you are no stranger to the term HTTP. I will also contribute some of my understanding of HTTP to everyone. Help people better understand HTTP and the evolution of HTTP.

Introduction to HTTP

HTTP_logo.svg.png

Before starting to learn about the development of HTTP, we must first know what HTTP is and then care about its development. So first, I will give the concept and a few things to pay attention to so that you can get an overview of HTTP.

Concept

HTTP (short for Hyper Text Transfer Protocol) is a data transfer protocol used in the World Wide Web(www) . It is an application layer protocol designed to transfer information between networked devices. It works based on the client-sever model where the web browser (Chrome, Edge, Safari, …) acts as the client (usually it is) and the server (sever) responds to requests. user demand.

HTTP-Protocol.png

HTTP is a stateless protocol which means that all requests are independent of each other. Requests will not know what was completed before. This simplifies communication between the client and the server, reducing the amount of data that needs to be transferred. If we want the requests to be linked together, we will need information shared from the server, such as the session id information in the cookie.

HTTP request

HTTP request is how the client sends a request for the information it needs to the server, the server will be responsible for responding to the information that the client wants.

Each HTTP request will contain some different type of information. A typical HTTP request would have:

  • HTTP version type: version of HTTP being used
  • URL: stands for Uniform Resource Locator used to identify a resource on the web. The URL will have the structure <protocol>://<domain>/<path> . For example, url: https://itzone.asia/p/gioi-thieu-ve-protocol-buffers-PwlVmx3wL5Z then https is protocol, itzone is sub domain, asia is domain name, p/gioi-thieu-ve-protocol-buffers-PwlVmx3wL5Z is the name and location of the resource
  • HTTP method: represents the request type of the request we will learn more about below
  • HTTP request headers: contains the information of the request we will learn more about below
  • HTTP body (may or may not): contains any information that the client wants to send to the server

HTTP method

The HTTP method represents the action type of the request. Some methods can be mentioned such as: GET, POST, PUT, PATCH, HEAD, … depending on the type of request, the purpose of the request will be different. For example, normally, GET will get data, POST shows that the client wants to send information to the server, …

HTTP request headers

HTTP request headers contain information stored as key-values, which are included in every request. The information in the headers is used to convey important information about the HTTP request. For example, thanks to headers, the server knows what information the client is requesting.

Example of HTTP request headers:

headers.PNG

HTTP request body

The HTTP request body contains any information that the client wants to send to the server depending on the purpose.

HTTP response

HTTP response is the information that the client receives from the server in response to the client’s HTTP request. Responses convey valuable information based on the HTTP request.

An HTTP request will contain:

  • HTTP status code: will be a code consisting of 3 numbers representing the status of the HTTP request
  • HTTP response headers: Just like HTTP request, HTTP response also has headers to contain important information.
  • HTTP body (may or may not): contains information returned to the client

HTTP status code

As explained above, the HTTP status code consists of 3 numbers representing the status of the HTTP request. It will be divided into 5 categories as follows:

  • 1xx Informational
  • 2xx Success
  • 3xx Redirection
  • 4xx Client Error
  • 5xx Server Error

Where xx will represent the numbers from 00 to 99. Status codes starting with the digit 2 represent that the HTTP request was successful. Starting with a 4 or 5 indicates an error has occurred and the web page will not be displayed. Similar to other error codes, you can learn more about them here

HTTP/1

HTTP/1 was introduced in 1996 and built on top of TCP. Requests sent to the server will require a TCP connection. Because it is a TCP connection, HTTP/1 uses a 3-way handshake mechanism to ensure that data has been fully sent and received between the client and the server. You can refer to the picture below.

handshake.PNG

HTTP/1.1

HTTP/1.1 was born in 1997, evolved from HTTP/1. It provides additional keep-alive mechanism so that TCP connection can be reused for multiple requests instead of each HTTP request initiating a TCP connection. This reduces request latency because the client will not need to initiate a TCP connection to perform a 3-way handshake for each request. HTTP/1.1 also adds a pipelining mechanism so that the client can send multiple requests at the same time without waiting for the response and the responses will be returned in the same order as the request was sent.

pipeline.PNG

HTTP/2

HTTP/2 was developed by Google and released in 2015, it adds HTTP streaming mechanism. The client can send stream requests to the server with a TCP connection. Unlike HTTP/1.1’s pipelining mechanism, each stream request is independent of the other and does not need to be sent and received responses in sequence.

HTTP/2 uses binary data which is more computer-friendly. Binary data helps us to reduce data redundancy and easily compress data. HTTP/2 compresses headers to reduce the redundancy of the request.

In addition, HTTP/2 provides another mechanism called sever push . When the browser requests a web page, the server returns HTML. Then the browser will parse the returned HTML and continue to execute the query to get files such as JS, CSS, … Thanks to server push, the server can not wait for the client request and send important information. important for the browser first. This will help minimize the delay when the browser has to parse the HTML and then continue to query the data => Speed ​​up page load time. This feature is especially useful for today’s web pages. However, we should not abuse it because it will backfire and reduce page load performance.

Epilogue

Through this article, I hope you will get an overview of the development of HTTP as well as clearly understand what HTTP is. In addition to the content mentioned in the article, HTTP and its versions also have some other functions but I did not mention. You can learn more about each version of HTTP in other articles. The above knowledge is also just my own research, so if there are any mistakes, I hope everyone can comment to improve the article. Thank you for watching until the end of the article.

Reference

HTTP evolution

BytebyteGo

Share the news now

Source : Viblo