uwsgi_cache_max_range_offset
Sets the maximum byte offset for range requests in uWSGI caching.
Description
The uwsgi_cache_max_range_offset directive specifies the maximum number of bytes that a range request can offset when the uWSGI caching mechanism is used in NGINX. Range requests allow clients to request only a portion of a file, identified by a byte range, which can be useful for resuming interrupted downloads or for streaming media.
When a client makes a request with a range header, this directive restricts how far into the content the request can go. If the specified offset exceeds the limit set by this directive, NGINX will respond with a status code indicating that the range is not satisfiable (HTTP 416). The value of this directive is specified in bytes, making it important to fine-tune it based on the expected usage patterns and content types served.
For instance, if uwsgi_cache_max_range_offset is set to 1024, clients can only request partial content offsets that are within the first 1024 bytes of the cached object. This can prevent excessive resource usage for large files and improve performance by limiting the extent of cache lookups and memory allocation required for serving partial content.
Config Example
location /app {
uwsgi_pass 127.0.0.1:9000;
uwsgi_cache my_cache;
uwsgi_cache_max_range_offset 2048;
}Setting a value too high may lead to excessive resource usage when handling range requests for large files.
Not setting this directive may lead to unexpected behavior with some clients expecting range-seeking functionality.