The browser and the server need to shake hands three times when establishing an HTTP connection. In a high-concurrency environment, a three-way handshake for each connection consumes too much service resources, this is essentially because HTTP is stateless. the connection = close mode is enabled by default in http1.0, which means both the server and the client need to close the TCP connection, and the client determines whether the response is received by judging whether the connection is closed. The connection = keep-alive mode (persistent connection) is enabled by default in http1.1. It is mainly used to solve the High-concurrency access to server resources in the browser, and the connection can be reused for each access, thus improving the response speed. However, you also need to note that the browser cannot determine whether the binary code stream currently sent is terminated, that is, the so-called stick packet problem. Therefore, in the keep-alive mode, the Content-Length returned by the server is used to determine whether a complete response ends Based on the code stream length.
Connection = keep alive and close