HTTP is a stateless connection-oriented protocol, an application-layer protocol that uses TCP at the transport layer, using IP at the network layerin HTTP 1.0, a short connection is used by default, and the browser and server make a connection every time HTTP operation is made, but the end of the task interrupts the connectionThe http1.1 uses a long connection by default to maintain the connection characteristics. This line of code is added to the response header:
Connection:keep-alive
When a long connection is used, the TCP connection is not closed, and if the client accesses the Web page on the server again, it will continue to use this established connection. The keep-alive has a hold time that can be set, essentially TCP's long connection and short connection. The operation steps for a
short connection are:Establish connection--data transfer--close connection ... Establish connection--data transfer--close connectionthe procedure for
long connections is:Establish connection--data transfer ... (Keep connected) ... Data transfer--close connection
Long connections are used to operate frequently, point-to-point communications, and the number of connections can not be too many cases.
concurrency is large, but each user needs to be short-connected without frequent operation.
HTTP long connections and short connections