Http1.0, HTTP1.1, http2.0, HTTPS comparison

Time:2021-5-11

http1.0

The previous HTTP version of 1.0 is a stateless, connectionless application layer protocol.
HTTP 1.0 stipulates that the browser and the server keep a short connection. Every request of the browser needs to establish a TCP connection with the server. The server immediately disconnects the TCP connection (no connection) after processing. The server does not track each client and does not record the past requests (stateless).
This stateless property can be used for identity authentication and state recording with the help of cookie / session mechanism. The following two problems are more troublesome.

shortcoming

The biggest performance defect caused by the connectionless feature is thatUnable to reuse connection. Every time you send a request, you need to make a TCP connection, and the TCP connection release process is more cumbersome. This connectionless feature makes the network utilization very low
Http1.0, HTTP1.1, http2.0, HTTPS comparison

advantage

HTTP1.1 supports pipelining, but the server must also send back the response one by one, which is a big defect. In fact, the current browser manufacturers have adopted another approach, which allows us to open multiple TCP sessions. In other words, the parallelism we see in the figure above is actually HTTP requests and responses on different TCP connections. This is also the limitation of our familiar browser to load 6 ~ 8 resources in parallel in the same domain. And this is the real parallel!

http1.1

Problem solving·

For long connection, HTTP1.1 adds a connection fieldKeep-AliveIt can keep the HTTP connection open, avoid the repeated establishment and release of each client and server request, and improve the utilization of the network. If the client wants to close the HTTP connection, it can carry it in the request headerConnection: falseTo tell the server to shut down the request.

Pipelining

Pipelining
The server must send back the corresponding results according to the client’s request order in order to ensure that the client can distinguish the response content of each request.

Strong cache

HTTP1.1 also adds cache processing (strong cache and negotiation cache [portal]) new fields, such as cache control, supports breakpoint transmission, and adds the host field (enabling a server to create multiple web sites).

https

Http1.0, HTTP1.1, http2.0, HTTPS comparison

http2.0

Http1.0, HTTP1.1, http2.0, HTTPS comparison

Head compression

In http1. X, header metadata is sent as plain text, which usually adds 500-800 bytes to each request.
For example, cookie. By default, the browser will attach the cookie to the header and send it to the server at each request( Due to the large size of the cookie and repeated sending each time, it is generally not used to store information, but only used for status recording and identity authentication.)

Http2.0 uses encoder to reduce the size of the header to be transmitted. Both sides of the communication cache a header fields table, which not only avoids repeated header transmission, but also reduces the size of the header to be transmitted. Efficient compression algorithm can greatly compress the header, reduce the number of packets sent, thus reducing the delay.

Server push

In addition to the response to the initial request, the server can push additional resources to the client without the explicit request of the client.

summary

HTTP1.0

No state, no connection
HTTP1.1

Persistent connection
Request pipelining
Add cache processing (new fields such as cache control)
Add host field, support breakpoint transmission, etc
HTTP2.0

Binary framing
Multiplexing (or connection sharing)
Head compression
Server push