slowfs_cache_min_uses

The `slowfs_cache_min_uses` directive specifies the minimum number of times a static file must be accessed before it is cached.

Syntaxslowfs_cache_min_uses number;
Default1
Contexthttp, server, location
Arguments1

Description

The slowfs_cache_min_uses directive is part of the NGINX SlowFS Cache Module, which is designed to improve the performance of serving static files from slower filesystems by temporarily caching them on faster storage. When a file is served, the cache mechanism evaluates how many times the file has been accessed. If the number of accesses reaches or exceeds the value set in slowfs_cache_min_uses, the file is then copied to the cache for faster subsequent delivery.

This directive accepts a single argument, which represents the minimum access count required for caching. Its default value is 1, meaning that even if a file is accessed just once, it will be cached. This parameter can be configured at multiple contexts, including http, server, or location, allowing for flexibility based on specific requirements of different server blocks or locations within your configuration. Setting this number to a higher value can help in cases where you want to avoid caching files that are less frequently accessed, thus optimizing storage and improving cache hit ratios.

The functionality of slowfs_cache_min_uses can be particularly beneficial in environments where static content experiences variable load patterns, ensuring that only widely used static resources are kept in the faster cache, ultimately improving overall performance.

Config Example

http {
    slowfs_cache_path /path/to/cache;
    slowfs_cache_min_uses 5;
}

Setting slowfs_cache_min_uses to a very high value might delay caching of files that are actually frequently accessed, reducing the effectiveness of the caching mechanism.

If the value is set to 1, files are cached immediately after the first access, which might lead to ballooning cache sizes if not monitored properly.

← Back to all directives