lingering_time

The 'lingering_time' directive in NGINX specifies the period to wait for requests before closing a connection.

Syntaxlingering_time seconds;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The 'lingering_time' directive is used to control how long NGINX will wait for further requests from a client before tearing down a connection, allowing for a grace period to enhance user experience by accommodating late requests. This feature can be beneficial in situations where a client might send additional requests right after the previous one has been received. The argument for 'lingering_time' is measured in seconds and determines the duration of this waiting period.

When a client closes the connection (e.g., a browser tab closes), NGINX can still keep the connection open for a specified 'lingering_time' if this directive is set. During this time, if another request is received from the same client, NGINX can process it without establishing a new connection, thus improving response times and reducing resource consumption. The directive can be useful in high-traffic environments where maintainable connections can lead to reduced latency and better overall performance.

Config Example

http {
    lingering_time 10;
    server {
        listen 80;
        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}
⚠

Setting 'lingering_time' too high may lead to resource exhaustion as connections remain open longer than necessary, affecting server performance.

⚠

If not set properly, clients may experience abrupt terminations of their connections due to server resource limits.

⚠

This directive may be less effective over HTTP/2 connections which have their own connection management principles.

← Back to all directives