scgi_cache_min_uses
Sets the minimum number of times an SCGI request must be accessed before it is cached.
Description
The scgi_cache_min_uses directive specifies the minimum number of requests that must be sent to a specified URL before the response is cached. This directive is particularly useful in high-traffic environments where the caching mechanism can become a bottleneck if frequently accessed responses are not stored. By setting a threshold, you avoid caching responses that may not be reused often, thus improving server efficiency and reducing unnecessary cache usage.
This directive accepts a single argument, which is a positive integer. When a request meets or exceeds the specified number of accesses, the response is cached based on the established caching rules. If not, the response will not be stored in the cache, allowing for real-time data retrieval. Additionally, when this number is set appropriately according to application usage patterns, it can help optimize resource usage, considering both memory space and disk I/O operations associated with caching.
It is important to note that the directive operates under the broader scgi_cache settings. Therefore, to leverage the benefits of scgi_cache_min_uses, the scgi_cache directive should also be defined to enable caching functionality on SCGI responses. When combined effectively, these directives enhance the performance of applications relying on SCGI by reducing response times for repeated requests.
Config Example
scgi_cache_path /etc/nginx/scgi_cache;
scgi_cache_min_uses 3;
location /api {
scgi_pass backend;
scgi_cache scgi_cache;
}If scgi_cache is not enabled, scgi_cache_min_uses will have no effect.
Setting scgi_cache_min_uses too high may result in too few items being cached, impacting performance in high-demand situations.
Ensure that proper caching rules are established alongside scgi_cache_min_uses for effective caching behavior.