Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Connection: keep-alive still being specified in http headers (isn't it deprecated)?

According to "HTTP: The Definitive Guide", using

Connection: keep-alive

to specify a persistent connection is deprecated in HTTP/1.1, since HTTP/1.1 specifies that connections are persistent by default and must be closed manually by sending

Connection: close


Thus, my simple assumption is that "Connection: keep-alive" shouldn't really be used anymore. However, it still seems alive and well. For example, keep-alive is being returned in the following query:

curl -I https://foursquare.com

HTTP/1.1 200 OK
Server: nginx/0.8.52
Date: Thu, 11 Aug 2011 21:15:45 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Expires: Thu, 11 Aug 2011 21:15:45 UTC
Set-Cookie: XSESSIONID=w19~kqtn4bpqmfq51p8qolstpk6ti;Path=/;Secure;HttpOnly
Set-Cookie: LOCATION=49.25::-123.13330078125::Hockeytown::CA;Path=/;Secure
Set-Cookie: bbhive=OQ32XATE0OQAEVCY0IVSWUDPQ1A2GT
Content-Length: 38815
Cache-Control: no-cache, private, no-store
Pragma: no-cache

My question is: Why is Connection: keep-alive still being specified in HTTP headers?

A corollary question is: Are there still (clients, servers, proxies, etc) that still only speak HTTP/1.0 and its variants, or are most such entities on HTTP/1.1 as of 2011?

Here are my working hypotheses:

1) HTTP/1.0 is no longer in use, b/c that was "many years" ago

2) Given (1), keep-alive shouldn't be used anymore, but is purely for vestigial reasons (that is, certain technologies haven't bothered to remove it, or keep it around as voodoo code, etc.)

If (1) is incorrect, and HTTP/1.0 is still in use, then sure it seems plausible to keep using keep-alive, despite follow-up questions on HTTP 1.0-1.1 interop.

Thanks in advance for any insights shared!

like image 203
capdigi Avatar asked Aug 11 '11 21:08

capdigi


People also ask

What does connection keep alive mean in HTTP?

HTTP keep-alive, a.k.a., HTTP persistent connection, is an instruction that allows a single TCP connection to remain open for multiple HTTP requests/responses. By default, HTTP connections close after each request.

How do I close the connection keep alive?

Use “KeepAlive On” to enable it. To disable, just use “KeepAlive Off”. It sets the maximum number of requests for every Keep-Alive connection.

Which version of HTTP uses the keep alive message to keep a connection open?

Since late 1996, developers of popular products (browsers, web servers, etc.) using HTTP/1.0, started to add an unofficial extension (to the protocol) named "keep-alive" in order to allow the reuse of a connection for multiple requests/responses.

How do you make a connection keep alive header?

The Keep-Alive header is a general-type header. This header is used to hint at how the connection may be used to set a timeout and a maximum amount of requests. It can also be used to allow a single TCP connection to remain open for multiple HTTP requests/responses (default HTTP connection closed after each request).


1 Answers

HTTP/1.0 have no headers like Connection, but there is many different implementation of HTTP/1.0 and HTTP/1.1.

so Connection: keep-alive is used 'Just in case'

like image 133
TheHorse Avatar answered Nov 15 '22 21:11

TheHorse