Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 18 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.

Optionally requests may be pipelined, though this still has some disadvantages, so multiple (2–5) connections are often used.

HTTP/2 (aka SPDY) was specifically designed to multiplex many requests at the same time.

Resources: Wikipedia article and RFC 2616 section 8.1.

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
Why Wireshark instead of Fiddler? – Pacerier May 21 '15 at 10:39
Fiddler is 1. Not an Open Source software; 2. Windows-only. – Vi. May 22 '15 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .