This is the 14th day of my participation in the August More Text Challenge

HTTP / 0.9

  1. Only the request line, because a single request line is sufficient to express what you want to get
  2. Only the body of the response, because you only need to return data without telling the client the encoding, language, and so on
  3. The content of the returned file is transferred as an ASCII character stream, since the HTML file is retrieved

HTTP / 1.0

  1. Add a request line that tells the server what type of file to return, what form of compression to take, what language to provide, and the exact encoding of the file
accept: text/html
accept-encoding: gzip, deflate, br
accept-Charset: ISO-8859-1,utf-8
accept-language: zh-CN,zh
Copy the code
  1. Response headers are added, such as the Content-Encoding field that tells the browser the final compression type

content-encoding: br content-type: text/html; charset=UTF-8

  1. Plus the status code
  2. Cache mechanism, used to Cache downloaded data
  3. User agent: used by the server to collect basic information about the client

HTTP / 1.1

  1. Change to persistent connection

By default, six TCP persistent connections can be established for the same domain name in the browser.

Connection: keep-alive
Copy the code
  1. The Host field is supported for virtual hosts
  2. Client Cookie and security mechanism
  3. Using CDN to achieve domain name sharding mechanism.

Cons: HTTP/1.1 is not very bandwidth efficient

  1. TCP slow start
  2. If multiple TCP connections are enabled at the same time, these connections compete for fixed bandwidth. And the inability to distinguish between critical resources and common resources leads to a universal slowdown
  3. HTTP/1.1 queue header blocking problem.

In a TCP connection, multiple HTTP requests wait until the first HTTP request is completed

HTTP/2

A domain name uses only one TCP long connection and eliminates queue header blocking issues.

TLS

A domain name uses only one TCP long connection to transfer data, realizing parallel requests for resources, and the server can also return the processed resources to the browser at any time

  1. Multiple recurrences: frames with ID numbers

HTTP multiplexing is implemented by adding a binary frame layer (plus ID numbers) to the protocol stack. Frame: The smallest unit of HTTP/2 data communication message: refers to the logical HTTP message in HTTP/2. Such as request and response, messages consist of one or more frames. Flow: A virtual channel that exists in a connection. Streams can carry bidirectional messages, and each stream has a unique integer ID 2. Priority of requests can be set 3. Server push, the browser does not need to initiate a request, the server actively push some important resources to the browser 4. The head of compression

Disadvantages:

  1. TCP queue header blocked:

In TCP transmission, the blocking caused by the loss of a single packet is called queue head blocking on TCP. In HTTP/2, multiple requests run through a TCP pipeline. If packet loss occurs in any of these streams, all requests in the TCP connection will be blocked. 2. The TCP connection establishment delay refers to the round trip time (RTT) for sending a packet from the browser to the server and then returning the packet from the server to the browser

HTTP/3:

Based on UDP to achieve similar to TCP multi-channel data flow, transmission reliability and other functions, we call this function QUIC protocol

QUIC agreement

  • It realizes the functions of flow control and transmission reliability similar to TCP.
  • Integrated TLS encryption function
  • The multiplexing function in HTTP/2 is realized

Unlike TCP, QUIC enables multiple independent logical data flows over the same physical connection (see figure below). Realize the separate transmission of data stream, and solve the problem of TCP squadron head blocking.

Realize the quick handshake function.