Thursday, July 1, 2010

How to enable Keep-alive?

Keep-Alive



Using persistent connections (keep-alive) is another great feature to be used for web application performance. HTTP is based on TCP, in early versions of HTTP a connection has to be opened for each request and closed later.


In later version this feature was introduces where browser and server use same connection to receive and send many requests on a single connection. This saves the overhead of opening and closing connections. On


Browser and server send a “connection” header to specify that they support keep-alive or persistent connections. Sample request and response headers can look like

Request header from browser

GET /images/imagecache/100x100_SW123.jpg HTTP/1.1
Host: youdomainname.com.ss
User-Agent: Mozilla/5.0 ( ...
Keep-Alive: 115
Connection: keep-alive



Response header for web server

HTTP/1.1 200 OK
Date: Sun, 20 Jun 2010 07:07:19 GMT
Last-Modified: Mon, 23 Jun 2008 11:59:38 GMT
Connection: keep-alive


How to enable Keep-alive?


Apache web server keep-alive is enabled by default. This configuration can be changed from apache configuration file.

No comments: