scgi_cache_lock_timeout

Sets the maximum time to wait for a cached response lock in NGINX SCGI caching.

Syntaxscgi_cache_lock_timeout time;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The scgi_cache_lock_timeout directive in NGINX HTTP Core module specifies the maximum duration to wait while trying to obtain a lock for a cached SCGI response. This is particularly useful when multiple requests for the same resource are being processed simultaneously. When a request is made, if the corresponding cached response is not available, a lock is acquired to prevent other requests from generating simultaneous SCGI requests for the same resource. This ensures that only one request is made upstream while others wait.

If the specified timeout is reached and the lock is not acquired, the pending requests will be served either an error or a stale cached version (if such behavior is enabled). Therefore, this directive helps in controlling how long requests should be held on standby when a cache miss occurs and prevents overwhelming the upstream server due to concurrent requests.

The value for scgi_cache_lock_timeout is set in seconds and allows for precise control over the server's behavior related to locking when it processes SCGI requests. The ability to define such a timeout can significantly enhance performance under load and improve response times for end users.

Config Example

scgi_cache_lock_timeout 5s;

Be careful with setting the timeout too high; it may lead to increased wait times for requests during cache misses.

If set too low, it may result in unnecessary cache misses as requests will error out before acquiring a lock.

← Back to all directives