How to enable HTTP persistent connection or HTTP keep-alive for your website for faster page speed using .htaccess file

As Wikipedia explains:

 

HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using a single TCP connection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair. The newer SPDY protocol uses the same idea and takes it further to allow multiple concurrent requests/responses to be multiplexed over a single connection.

 

Note: I assume you have adequate knowledge of handling your server & server settings & you are well versed in your field

 
You can put following code in your .htaceess file which is available in your root of your server’s html folder

 

<ifModule mod_headers.c> Header set Connection keep-alive </ifModule>

 
After completing above procedure you are good to go,

 
But know you may be wondering above settings are working or not i.e. Keep Alive settings are on or not on your domain

 
Now go to & open Terminal App available on OSX in Applications > Utilities folder

 

curl -Iv http://your-domain-name.com 2>&1 | grep -i 'connection #0'

 

Note: put your domain name in url of above code

 
Then after executing above code in Terminal, If you get result something like this:

 

* Connection #0 to host your-domain-name.com left intact

 
Understand that Keep Alive is working on your server for your domain.

 
Hope it helps,

 
Thanks & Regards
Mandar Apte

Mandar Apte

This website contains a design articles blog by Mandar Apte. He writes and shares his iOS development, graphic, web, & animation film design experience through articles. Mandar is Mumbai based multi-disciplinary designer with expertise in UI, UX, Logo, Symbol, and Brand Identity design. He is an alumnus of Sir J. J. Institute of Applied Art, Mumbai. He currently runs his studio in the heart of the city of Mumbai.

Leave a Reply

Your email address will not be published. Required fields are marked *