uwsgi_cache_path

The `uwsgi_cache_path` directive sets the cache path for caching uWSGI responses in NGINX.

Syntaxuwsgi_cache_path path [levels=levels] [max_size=size] [inactive=time] [use_temp_path=on|off];
Defaultnone
Contexthttp
Arguments2+

Description

The uwsgi_cache_path directive is used to define the file system location used for caching responses from uWSGI applications. This directive enables response caching, where responses from uWSGI handlers are stored on disk and can be served directly from the cache, reducing backend server load and improving response times. The main parameters for this directive include the cache key name, cache directory, and optional settings for cache size, inactive time, and levels of directories to use in the cache storage structure.

When configured, uwsgi_cache_path takes several configuration options such as the directory path to store cached data, the cache key name, the maximum size of the cache, and a specific inactive timeout for cached items. It is important that the cache directory is writable by the NGINX worker processes. The caching mechanism can significantly boost performance for applications that generate repetitive responses that can be cached, especially for static content or dynamic pages with rare changes.

Overall, this directive is typically combined with the uwsgi_cache directive, which specifies whether caching is enabled for specific uWSGI locations, and how caching behavior is managed in that context, thus integrating tightly with NGINX’s caching features to optimize application delivery.

Config Example

uwsgi_cache_path /var/cache/nginx/uwsgi_cache levels=1:2 max_size=10g inactive=60m use_temp_path=off;

Ensure the cache directory has the correct permissions for NGINX worker processes to write to it.

Be mindful of the cache size limit and clean up stale entries as needed to prevent disk space issues.

Incorrectly setting the levels option could lead to inefficient storage or performance issues.

← Back to all directives