The HTTP 1.0

In version 1.0 of HTTP, there was a problem: a connection was made that contained only one request response (that is, one resource).

If you have more than one request, it will be inefficient.

The HTTP 1.1

Connection: keep-alive is enabled by default in HTTP 1.1

A:Connection reuse

One connection can have multiple requests and responses (for multiple resources).

Improved 2:Pipeline (Pipeline)

The next request does not need to wait for the previous response.

But the order of response is the same, FIFO.

Remaining issues:

  • Requests are sequential, and subsequent arrivals need to wait in line.
  • Request headers are mostly similar, and repeated transfers waste resources.
  • Browsers in the same domain have a maximum concurrent request limit.

The HTTP 2.0

multiplexing

Since HTTP 1.x is text-based, because it is text, it must be a whole, uncleavable in transmission, only whole to be transmitted.

But HTTP 2.0 is based on binary streams. There are two very important concepts, frame and stream

  • Frames represent the smallest unit of data, and each frame identifies which stream it belongs to.
  • A stream is a data stream composed of multiple frames.

The HTTP message is broken up into individual frames, interleaved, and then reassembled at the other end.

  • Multiple requests are sent in parallel, interleaved, and do not affect each other.
  • Multiple responses are sent in parallel and interleaved so that the responses do not interfere with each other.
  • Send multiple requests and responses in parallel using a single connection.

To put it simply: Multiple requests and responses can be sent at the same time on the same TCP connection, and they don’t have to be sequentially mapped.

Previously, the same connection can only be used once. If keep-alive is enabled, it can be used multiple times, but only one HTTP request can be made at a time.