scgi_cache_max_range_offset

Configures maximum offset for SCGI cache range retrieval.

Syntaxscgi_cache_max_range_offset size;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The scgi_cache_max_range_offset directive specifies the maximum range offset when retrieving cached responses for SCGI requests. This directive allows users to set a specific byte range that can be requested from the cache, controlling how much data can be sent in response to a partial content request. By configuring this limit, you can effectively manage bandwidth usage and optimize caching behavior based on content types and expected client usage.

When a client requests a range of bytes from a cached SCGI response, NGINX checks if the requested range exceeds the limit defined by scgi_cache_max_range_offset. If the request exceeds this limit, NGINX may respond with an error or fall back to fetching the entire resource, depending on the failover configuration. This directive can be crucial in scenarios where extremely large cached objects may lead to excessive resource use or where precise control over delivered content is beneficial.

This directive accepts a single argument specifying the maximum range offset in bytes. It can be set on various contextual levels such as http, server, and location, allowing flexible implementation based on the structure of your NGINX configuration.

Config Example

location /api {
    scgi_pass unix:/var/run/scgi.sock;
    scgi_cache on;
    scgi_cache_path /tmp/scgi_cache levels=1:2 keys_zone=scgi_cache:10m;
    scgi_cache_max_range_offset 100000; 
}

Be cautious when setting a very high offset, as it could allow clients to request more data than intended, impacting server performance.

If not set, clients may receive the entire content if they request a range larger than the default behavior without efficient handling.

← Back to all directives