slowfs_cache_path

The `slowfs_cache_path` directive configures a cache area for files served from slow filesystems in NGINX.

Syntaxslowfs_cache_path path [levels] keys_zone=zone_name:zone_size [inactive] [max_size];
Defaultnone
Contexthttp
Arguments2+

Description

The slowfs_cache_path directive is integral to the NGINX SlowFS Cache Module, as it defines the cache location and structure for caching static files. This is particularly beneficial when files are stored on slow filesystems, such as networked disks or older SATA drives, and cached on faster local disks or more performant storage. By setting this directive, NGINX can then utilize this specified area to speed up the serving of these files by caching them after they have been accessed a specified number of times.

The directive can take several parameters: the path where the cache is stored, an optional levels argument to specify the structure of cache directories, and several optional parameters such as keys_zone to define a shared memory zone for managing cache keys, inactive to set a time period after which cache entries are considered stale, and max_size to limit the size of the cache. Configuring these parameters properly will ensure that the cache operates efficiently, allowing for quick access to frequently requested files while managing resource usage effectively.

In terms of operation, the directive must be placed within the http context. It is essential to note that multiple slowfs_cache_path directives can be declared, but they should ideally point to different areas or configurations for diverse content types or directories to optimize caching based on the unique performance characteristics of each storage medium being utilized.

Config Example

http {
    slowfs_cache_path /var/cache/nginx/slowfs 10 keys_zone=slowfs_cache:10m;
    slowfs_cache_min_uses 2;
    slowfs_big_file_size 256k;
}

Ensure that slowfs_cache_path and slowfs_temp_path point to the same filesystem to avoid unnecessary file duplication.

Be cautious with the max_size parameter to prevent caching failures due to size limitations.

The module may not work as intended if AIO (Asynchronous I/O) is enabled in the NGINX configuration.

← Back to all directives