Act Fast - Get 15% off GTmetrix PRO Plans now!

Valid only until August 31st - Use code SUMMER2022 to get 15% off the first year of any Yearly PRO Plan! Details and conditions

Recommendations

Lighthouse
Metrics
Audits
PageSpeed (Legacy)
YSlow (Legacy)

Lighthouse: Enable Keep-Alive

Overview

This is a custom GTmetrix Lighthouse Audit. Learn more.

For HTTP/1.1 requests, enabling Keep-Alive reduces latency and improves your page performance.

Browsers may use multiple TCP connections to retrieve your page's files from the server because the original connection was closed upon delivering the initial file. This increases latency and increases the time taken to load your page.

Enabling Keep-Alive allows the same TCP connection to be used for transferring multiple files, resulting in a faster loading page.

How does your site score on this audit?

How does enabling Keep-Alive affect page performance?

Enabling Keep-Alive ensures that a single TCP connection is used to transfer multiple files from the server to the browser. This helps your page load faster as the browser doesn't need to establish multiple connections to retrieve all your page resources.

In general, the browser establishes a TCP connection with a server so that it can retrieve your page's resources and display the page content.

With HTTP/1.1 requests, the browser can close TCP connections once it has fetched a particular file from the server. If multiple connections are opened to retrieve your page's files, it unnecessarily increases network latency, resulting in a slow loading page.

Enabling Keep-Alive provides an explicit declaration to the browser that it shouldn't close the connection upon receiving the file from the server.

Note that this audit is only applicable for HTTP/1.1 requests.

How does GTmetrix trigger this audit?

GTmetrix evaluates the response headers of your page resources and flags the requests that don't have Connection: Keep-Alive enabled.

This audit triggers if there is at least one such resource.

This is a Custom GTmetrix audit

While Lighthouse checks to see if your webpage uses HTTP/2, it doesn't check if Keep-Alive has been enabled on your web server.

Websites on HTTP/1.1 can open multiple TCP connections with a server to fetch the page resources. While many websites have moved to HTTP/2 and/or some web servers automatically transfer files over a single TCP connection, either of these may not be the case for some users.

We feel that users should be made aware of this simple setting that can drive performance gains for their webpages, which is why we continue to flag this audit on our reports.

How to enable Keep-Alive?

Depending on the webserver used to serve your resources, follow the below instructions:

1) For Apache servers

Apache enables Keep-Alive connections by default; however, you can explicitly turn them on by adding the following line to your httpd.conf file.

KeepAlive On

Having said that, if your site is running on a shared host, you probably won't have access to httpd.conf and will therefore have to live with whichever setting your hosting provider has chosen.

.htaccess warning

You may come across some suggestions elsewhere that adding the following code to your .htaccess file will enable Keep-Alive.

Header set Connection keep-alive

However, contrary to what these websites suggest, adding the above code to your .htaccess file will not actually enable Keep-Alive connections, but it will send browsers misleading information about the server's capabilities.

2) For Microsoft IIS servers

Copy and paste the following into the command line:

appcmd set config /section:httpProtocol /allowKeepAlive:true

3) For NGINX servers

Keep-Alive is enabled by default in NGINX.

Summary

 **

Cookie Policy

By clicking "Allow All" you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. View cookie details

Deny Allow All
×