From The Server To The Web Browser: What Goes On?

Every time you click on a link in a web page or type a URL into your web browser you are in fact making a ‘request’ for a certain document. That request is carried out with the Hyper Text Transfer Protocol (HTTP) and sent over the Internet all the way to the server which is keeping the document in question. If everything goes well the server responds by sending the document, which is usually a web page of text and graphics.

The HTTP is part of the Internet Protocol(IP) suite. It is used by the ‘client’ which here is the web browser in order to create a connection with the server which hosts a website in particular. The server waits for incoming requests by monitoring TCP port 80.

Transmission Control Protocol (TCP) is used to produce connections between two computers on the Internet so that they can exchange data. TCP has provisions for identifying the requesting computer and also for transmitting information with time stamps so that it can be gathered again in the correct order once it arrives to its destination.

There are many standardized uses for TCP ports. For example, TCP port 21 is usually reserved for FTP (File Transfer Protocol) in order to upload and download files. Port 80 is usually employed for HTTP.

If your server gets a request string on TCP port 80 in the shape of GET / HTTP/1.1 it will send a response code which will depend on whether the requested web page is available or not. A classic request goes like this:

GET /faq.html HTTP/1.1
Host: http://www.mywebsite.com

This will be a request for http://www.mywebsite.com/faq.html. The ‘Host’ needs to be specified in order to distinguish websites which are hosted on shared servers. If faq.html is available the server will then reply:

HTTP/1.1 200 OK
Date: Mon, 12 October 2005 22:38:34 GMT
Server: Apache/1.3.27 (Unix)(Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT

…followed by the actual web page.

HTTP/1.1 200 OK signifies that the web page you requested is available. Other codes can also be returned. For example, the code 404, signifies that the server cannot find the page you requested. The web page is sent through TCP as a set of data packets with a header each that will specify its destination and order in the data stream. The various packets can all take on various routes in order to reach their target. Each packet is sent through a router which polls other routers which are near by. However, if a connection with the first router is unavailable, the data will be sent through another one.

As the data is received, the client (web browser) will send back an acknowledgement. This will ensure that all the packets are received within the right amount of time. If they aren’t, they will be re-transmitted by the server. TCP will also check that the data is not damaged. The data will be rearranged in the right order thanks to the sequence number of each data packet. And there you go! Then the web page appears on your computer screen.

Also, the TCP connection can be kept alive for further requests from the client. This will enable several pages to be requested within a short span of time without causing the overhead to open and close TCP ports. The client or the server can end the connection any time by just closing it.


J. M. Stevens is contributing editor at WebDesignArticles.net. This article may be reproduced provided that its complete content, links and author byline are kept intact and unchanged. No additional links permitted. Hyperlinks and/or URLs must remain both human clickable and search engine spiderable.