How HTTP connection works ?

When you try to access particular URL in your browser it goes through following steps to get response


  • First browser needs to determine the IP address and port number of the web server from the URL. If the host name in the URI was not recently visited it may take tens of seconds to convert the host name from a URI into an IP address using the DNS resolution infrastructure

  • Next the client sends a TCP connection request to the server and waits for the sever to send back a connection acceptance reply. Connection setup delay occurs for every new TCP connection. This usually takes a second or two but it can add up quickly when hundreds of Http transactions are made.

  • Once the connection is established, the client sends the HTTP request over the newly established TCP pipe. The web server reads the request message from the TCP connection as the data arrives and processes the request. It takes time for request message to travel over the internet and get processed by the server

  • The web server then writes back the Http response, which takes some time



YOu can use Firebug to loot at the time spent by browser in each of these steps, take a look at following screen shot



Firebug will display timeline for each of the resource, different colors in the timeline display time spent in each of the phase of getting response, when you take your mouse over particular resource it will display a popup with details on time spent in each phase


  • DNS Lookup This is amount of time it took for Firefox to figure out IP address and port number from the URL. Please note that Firefox will cache the results of DNS lookups. This time is longer for first request to host name

  • Connecting This is amount of time it took for Firefox to establish Http connection with the server

  • Sending This is amount of time it takes for Firefox to send the request

  • Waiting Time taken for server to read the request process it and start sending message

  • Receiving Time taken for firefox to receive the response sent by server

1 comment:

Anonymous said...

great useful article. thanks!