uwsgi_cache_min_uses

The `uwsgi_cache_min_uses` directive specifies the minimum number of times a request must be made before it is cached.

Syntaxuwsgi_cache_min_uses number;
Default1
Contexthttp, server, location
Arguments1

Description

The uwsgi_cache_min_uses directive is part of the NGINX caching mechanism specifically used with uWSGI requests. It allows you to define a threshold for how many times a specific request must be processed before it's eligible for caching. This can be particularly useful for controlling cache longevity and performance, as it prevents infrequent requests from consuming cache space unnecessarily.

This directive accepts a single argument: an integer value that indicates the minimum usage threshold. For instance, if set to 3, a specific request must be made at least three times before the response is stored in the cache. If the number of requests falls below this limit, the response would not be cached, which could be beneficial in a high-traffic environment where not all requests are worth caching. This helps optimize the cache usage and can improve the overall performance of your application by ensuring that the cache holds only the most frequently requested responses.

It's important to note that this directive should be used thoughtfully, as setting the threshold too high may prevent valid responses from being cached, while setting it too low might lead to excessive caching of responses that only occur infrequently. Therefore, it is advisable to evaluate the traffic patterns and adjust this directive accordingly to achieve the desired caching behavior.

Config Example

uwsgi_cache_min_uses 3;

Setting the value to 1 may result in excessive cache usage, as all responses will be cached immediately after the first request.

If the total number of requests is too low, some useful responses may never be cached if the threshold is set too high.

← Back to all directives