Home  >  Article  >  Web Front-end  >  HTTP persistent connection and pipeline

HTTP persistent connection and pipeline

yulia
yuliaOriginal
2018-09-08 17:45:002179browse

1.What is a persistent connection? (keep alive mode)
HTTP1.1 stipulates that the default connection is to keep a long connection (HTTP persistent connection, also translated as persistent connection); after the data transmission is completed, the TCP connection is not disconnected (no RST packets are sent, no four times Handshake), waiting to continue using this channel to transmit data under the same domain name; the opposite is a short connection.

HTTP version 1.1 supports persistent connections but version 1.0 does not support
Differences from non-persistent connections:
Persistent connections enable the client-to-server connection to remain valid and avoid re-establishing the connection
Greatly Reduces connection establishment and closing delays. HTTP connections are based on the TCP protocol. Establishing a TCP connection requires three handshakes, and closing the TCP connection requires four waves. These all take time.

2. What is pipelined
The pipelined mechanism must be completed through a persistent connection. Only HTTP/1.1 supports this technology (HTTP/1.0 does not support it) )
In the case of using a persistent connection, the delivery of a connection message is similar to
Request 1 -> Response 1 -> Request 2 -> Response 2
Pipeline: on a connection The message becomes something like this
Request 1 -> Request 2 -> Request 3 -> Response 1 -> Response 2 -> Response 3

[Note]

a. The difference between persistent connections and pipelined connections is that one disadvantage of persistent connections is that requests and responses are executed sequentially. Request 2 will be sent only after the response to request 1 is received. , and pipeline processing does not need to wait for the response of the previous request to proceed with the next request. Implement sending requests in parallel.

b. Only GET and HEAD requirements can be pipelined, while POST is restricted

c. The pipeline mechanism should not be started when the connection is first created, because the other party (server ) does not necessarily support the HTTP/1.1 version of the protocol

d. HTTP1.1 requires the server to support pipelined processing, but it does not require the server to also pipeline the response. It only requires that pipelined requests not be processed. Failed, and many server-side and agent programs currently do not have good pipeline support. Modern browsers Chrome and Firefox do not enable pipeline support by default. HTTP persistent connection and pipeline

The above is the detailed content of HTTP persistent connection and pipeline. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn