HTTP is statel-less,so what does it mean by keep-alive?

前端 未结 5 1954
慢半拍i
慢半拍i 2021-02-07 10:49
Keep-Alive: 300
Proxy-Connection: keep-alive

As we know HTTP connection is closed when the request gets responded,so what does it mean by keep-al

5条回答
  •  执笔经年
    2021-02-07 11:37

    As we know HTTP connection is closed when the request gets responded

    What is an HTTP connection? Actually, it's a socket connection over which HTTP is implemented. Only in HTTP1.0 does the connection get closed after each response. In order to save on the cost of setting up a TCP/IP connection, HTTP1.1 specifies that unless the client sends a header

    Connection:close
    

    or the server comes back with the same header, then the socket remains open. You can feed as many requests as you want into this socket and the responses will come back in the order that they were requested. This requires that the response is either sent with a chunked transfer encoding or contains a content-length header so that the end of each response can be detected/calculated.

    The proxy-connection header is different again, and is related only to the conversation between client and proxy servers.

    I'd recommend this page as an excellent guide to the protocol.

    HTTP Made Really Easy

提交回复
热议问题