Principles of keepalive
Both http1.0 and http1.1 support keepalive. Http1.0 requires "connection: keep-alive" header to be added to the request, whereas http1.1 supports this header by default.
The data interaction process supported by http1.0 keepalive is as follows:
A) when the client sends a request, the HTTP Version of the request is 1.0. The request contains a header: "connection: keep-alive".
B) the Web server receives the request The HTTP protocol 1.0 and "connection: keep-alive" in is considered to be a persistent connection request, and "connection: keep-alive" will be added to the header of the response. The established TCP connection will not be closed.
C) when the client receives a response from the web server that contains "connection: keep-alive", it considers it a persistent connection and does not close the TCP connection. Use the TCP connection to send the request again. (Jump to ))
The data interaction process supported by http1.1 keepalive is as follows:
A) when the client sends a request, the HTTP Version of the request is 1.1.
B) when the HTTP protocol in the request is 1.1, the web server considers it a persistent connection request and adds "connection: keep-alive" to the header of the response. The established TCP connection will not be closed.
C) the client receives Response contains "connection: keep-alive", which is considered to be a persistent connection and does not close the TCP connection. Use the TCP connection to send the request again. (Jump to a)