What is the difference between Connection and Proxy-connection in HTTP header?
The Connection
header is a standard header defined in the HTTP 1.0 and 1.1 specifications (RFC 2068 and RFC 2616) for maintaining keep-alive behaviour on an HTTP connection.
Proxy-Connection
was an experimental header created by the Netscape developers to do similar things due to a misunderstanding about when Connection
header could be used. It has never worked properly and is ignored by many of the common HTTP systems in existence today. When it does work as designed there is no difference between the two.
Quoted from https://www.rfc-editor.org/rfc/rfc7230#appendix-A.1.2
In HTTP/1.0, each connection is established by the client prior to the request and closed by the server after sending the response. However, some implementations implement the explicitly negotiated ("Keep-Alive") version of persistent connections described in Section 19.7.1 of [RFC2068].
Some clients and servers might wish to be compatible with these previous approaches to persistent connections, by explicitly negotiating for them with a "Connection: keep-alive" request header field. However, some experimental implementations of HTTP/1.0 persistent connections are faulty; for example, if an HTTP/1.0 proxy server doesn't understand Connection, it will erroneously forward that header field to the next inbound server, which would result in a hung connection.
One attempted solution was the introduction of a Proxy-Connection header field, targeted specifically at proxies. In practice, this was also unworkable, because proxies are often deployed in multiple layers, bringing about the same problem discussed above.
As a result, clients are encouraged not to send the Proxy-Connection header field in any requests.
Clients are also encouraged to consider the use of Connection: keep-alive in requests carefully; while they can enable persistent connections with HTTP/1.0 servers, clients using them will need to monitor the connection for "hung" requests (which indicate that the client ought stop sending the header field), and this mechanism ought not be used by clients at all when a proxy is being used.