The Keep-Alive HTTP header is an important part of the HTTP protocol. It was created to make web pages load faster by reducing the number of requests required per page. The client will assume that it can continue to communicate with a server for a certain amount of time before needing to refresh or reload, which saves bandwidth and processing power on both ends. In this blog post, we’ll go over some basics about what Keep-Alive header.
What is Keep-Alive?
Keep-Alive is an HTTP header that assists in keeping web connections open by allowing browsers to make multiple requests per connection. Websites on a server that runs HTTP/1 often have keep-alive enabled to improve their performance. The Keep-Alive HTTP header is not required when using the HTTP/2 protocol as it is enabled by default.
Keep-Alive headers are optional, but they can help save bandwidth and processing power by reducing the number of requests per page. The client will assume that it can continue to communicate with a server for a certain amount of time before needing to refresh or reload – which saves bandwidth and processing power on both ends.
Keep-Alive is a way to maintain persistent connections between the web server and clients (visitors) when it is enabled. The connection stays open until you close it. It takes time to complete the process that connects a browser and a web server. Connecting many times increases this load time, so by combining multiple connections into one with Keep-Alive benefits everyone.
The disadvantage of Keep-Alive is that it uses more system resources. If websites on a server get a lot of visitors, they can have several connections open at the same time. That will lead to server’s resource overload and crash.
Apache servers have specific directives to prevent them from reaching capacity. Some of these directives belongs to Keep-Alive header, which define a browser from making more than certain request for an object on a single TCP link at the same time and maximum time of a query too reduce network bandwidth. With right setting, we can prevent server crash.
- KeepAliveTimeout – A persistent connection is when a computer waits for new requests and this defines the maximum period a connection is alive.
- MaxKeepAliveRequests – This determines the largest number of requests which a single connection can send.