slowfs_cache

The `slowfs_cache` directive activates caching for static files served from slow filesystems.

Syntaxslowfs_cache zone_name;
Defaultnone
Contexthttp, server, location
Argumentsflag

Description

The slowfs_cache directive is used to specify which cache zone to utilize for caching static files that are hosted on slow filesystems, enabling the serving of these files from a faster cache layer. This feature is particularly beneficial when dealing with static files that originate from slow storage media, such as network disks or traditional spinning hard drives, allowing them to be cached on faster local disks or SSDs. The configuration requires that the cache zone be pre-defined using the slowfs_cache_path directive, which creates the cache area for storing these files.

When the slowfs_cache directive is enabled, it allows NGINX to store requests for static files that are too slow to retrieve directly from the origin server, thus reducing wait times for clients. The caching mechanism operates by recording successful requests after a specified number of uses defined by the slowfs_cache_min_uses directive. During subsequent requests, files are served from the cache without needing to access the slow filesystem, streamlining response times.

Config Example

http {
    slowfs_cache_path /tmp/slowfs_cache 10 20 keys_zone=slowfs_cache:10m;
    slowfs_cache slowfs_cache;

    location /static/ {
        root /path/to/static/files;
    }
}

Ensure the cache zone is defined using slowfs_cache_path before using this directive.

Using slowfs_cache without appropriate cache storage may lead to unexpected behavior.

This module does not function correctly with Asynchronous I/O enabled.

← Back to all directives