proxy_cache_max_range_offset

The 'proxy_cache_max_range_offset' directive sets the maximum allowed range offset for proxied cached responses in NGINX. — NGINX HTTP Core

proxy_cache_max_range_offset
httpserverlocation
Синтаксисproxy_cache_max_range_offset size;
По умолчаниюnone
Контекстhttp, server, location
МодульNGINX HTTP Core
Аргументы1

Описание

The 'proxy_cache_max_range_offset' directive is utilized within the contexts of http, server, and location blocks of an NGINX configuration. It is designed to specify the maximum range offset that can be accepted for a response that is served from the proxy cache. By default, NGINX will allow any range request that does not exceed this specified offset value, which effectively helps optimize the caching mechanism when dealing with byte ranges in large media files or other content.

Пример конфига

http {
    proxy_cache_path /tmp/cache levels=1:2 keys_zone=my_cache:10m max_size=1g;
    server {
        location /media {
            proxy_pass http://backend;
            proxy_cache my_cache;
            proxy_cache_max_range_offset 1048576;  # 1 MB
        }
    }
}

Ensure the value specified is appropriate for the content being served; too high a value may lead to excessive memory usage for large media files.

This directive only applies if the content is served from the proxy cache; enabling proxy caching is a prerequisite.