Enabling Keepalive for Faster Webpages


Enabling keepalive is a way to help your browser and server communicate more efficiently. Instead of having to open multiple connections for a webpage, you can keep one connection open, allowing content to be delivered more quickly. So, how do you do it?

In your requests, the headers appear after the request or response line. To enable keepalive, you have to add an HTTP header. What you’re doing is tell your server that the connection should stay open. If you have access to your webserver config file, it’s easy enough to go in and see what your header says. If you see, “connection: close,” then you know that keepalive is disabled. Changing it to “connection: keep-alive” will remedy that.

If you do not have access to the config file, then you can change the header using .htaccess. This is just a text file that you can create and save in the web directory. When you’ve created or opened .htaccess, add:

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

You’ve enabled keepalive, and your page should see some improvements in speed. Just a word of caution: changing your .htaccess file can cause a domino effect on your website, so before you add your new header, make sure you make a copy.

Leave a Comment