Network foundation: HTTP (5): The advantages and characteristics of HTTP2 over HTTP1.X

1. Binary framing
Frame: The smallest unit of HTTP/2 data communication. Message: Refers to the logical HTTP message in HTTP/2. For example, request and response, etc. The message consists of one or more frames.

Flow: A virtual channel that exists in the connection. Streams can carry bidirectional messages, and each stream has a unique integer ID.

HTTP/2 uses the binary format to transmit data, instead of the text format of HTTP1.X, the binary protocol is more efficient to parse.

2. Header compression
HTTP/1.x will repeatedly carry infrequently changed and lengthy header data in requests and responses, which will bring additional burden to the network.

①HTTP/2 uses the "header table" on the client and server to track and store the previously sent key-value pairs. For the same data, it is no longer sent through each request and response.

②Each new first key-value pair is either appended to the end of the current table, or replaces the previous value in the table.

③ The header table always exists during the continuous storage period of HTTP/2, and is gradually updated by the client and server.

(It can be understood that only the difference data is sent instead of all, thereby reducing the amount of information in the header.)
Insert picture description here
Third, the server push The
server can actively push other resources when sending page HTML, instead of waiting for the browser to parse the corresponding position and initiate The request is responding. For example, the server can proactively push js and css files to the client, instead of sending these requests when the client parses the HTML.

The server can actively push, and the client has the right to receive it. If the resource pushed by the server has been cached by the browser, the browser can reject it by sending a RST_STREAM frame. Active push also complies with the same-origin policy, and the server will not randomly push third-party resources to the client.

4. Multiplexing
1. In HTTP1.x, if you want to send multiple requests concurrently, you must use multiple TCP links, and in order to control resources, the browser also has a 6-8 TCP link request limit for a single domain name.

2. In HTTP2: ①All
communications with the same domain name are completed on a single connection ②A
single connection can bear any number of bidirectional data streams.
③The data stream is sent in the form of a message, and the message is composed of one or more frames, and multiple frames can be sent out of order because it can be reassembled according to the stream identifier in the frame header.
Insert picture description here

Guess you like

Origin blog.csdn.net/imagine_tion/article/details/110404178