scgi_cache_path

The `scgi_cache_path` directive defines a location for storing SCGI responses, enabling caching for improved performance.

Syntaxscgi_cache_path path zone=name:size [levels=levels] [max_size=size] [inactive=time];
Defaultnone
Contexthttp
Arguments2+

Description

The scgi_cache_path directive in NGINX is used to specify a cache location for SCGI responses, allowing the server to store and serve SCGI responses from this cache efficiently. This directive takes two or more arguments: the path to the cache directory, the key zone, and optionally, cache parameters such as the maximum size and inactive time. The first argument defines the file system path where cached SCGI responses will be stored, and the second argument specifies the zone that NGINX should use for determining the caching key and other related configurations.

When an SCGI response is requested, NGINX first checks the defined cache path to see if the response exists. If it does, the response is served from cache, greatly improving response times and reducing the load on upstream SCGI servers. If the response is not in the cache, NGINX forwards the request to the upstream SCGI server, caches the response upon retrieval, and serves it to the client as well as storing it for future requests. Additionally, the cache can be configured with parameters with options that specify limits for size and expiration of cached items, allowing for efficient memory usage over time.

Config Example

scgi_cache_path /var/cache/scgi_cache scgi_cache_zone 10m max_size=1g inactive=60m;

Ensure the cache directory is writable by the NGINX process.

Properly specify the cache zone to avoid misconfigurations.

Monitor cache size to prevent excessive disk usage.

← Back to all directives