Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I know that HTTP is basically just a text protocol over TCP, and that TCP is state / connection based. That means that the browser has to connect over TCP to a server before doing an HTTP request. Question then: do browsers typically create a new TCP connection for each HTTP request?

Browsers could just open a TCP request and keep it alive as long as the user is still browsing on that server, but then servers would have to use a big amount of maximum connections to handle that. But then again, if the browsers create a connection for each request, and the user browses a lot on the same server, that would seem like a waste. How does it usually work? Maybe through use of a timer?

share|improve this question

2 Answers 2

up vote 15 down vote accepted

In HTTP/0.9 (not used anymore), each request uses a separate TCP connection, and the end of a response is signalled by closing the connection.

In HTTP/1.0, an unofficial but very widely supported "Connection: Keep-Alive" request header can be used to request a persistent connection if the server supports it.

In HTTP/1.1, persistent connections are the default, and the old single-request behavior has to be requested explicitly.

Resources: Wikipedia article and RFC 2616 section 8.1.

See also: HTTP pipelining (another HTTP speed improvement) and SPDY (an alternative protocol proposed by Google).

share|improve this answer

There is "Connection: Keep-Alive" header. See enwiki for details.

You can use Wireshark to capture and analyse connections and see all headers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.