uwsgi_no_cache

The `uwsgi_no_cache` directive specifies a condition under which responses from the uWSGI server should not be cached.

Syntaxuwsgi_no_cache string | $variable ;
Defaultnone
Contexthttp, server, location
Arguments1+

Description

The uwsgi_no_cache directive is used in NGINX configurations to prevent certain responses from being cached based on specified parameters. When this directive is defined with one or more arguments, it informs NGINX to not cache responses for any requests that match those arguments. This is particularly useful in situations where the content must always be freshly retrieved from the uWSGI application server, such as dynamic content that changes frequently.

The arguments for uwsgi_no_cache can include variables that evaluate to conditions or values, enabling fine-grained control over caching. For example, one might specify certain request headers or status codes that cause a response to be marked as non-cacheable. This directive is context-sensitive and can be used in various scopes including http, server, and location, allowing for flexible caching strategies throughout an NGINX configuration.

When the conditions specified are met, the response is handled by NGINX without being stored in its caching mechanisms, ensuring that users always receive the latest content. If the directive is not specified, NGINX may cache eligible responses based on default caching settings, which might lead to outdated content being served.

Config Example

location /app {
    uwsgi_pass  unix:/tmp/uwsgi.sock;
    uwsgi_no_cache $http_cache_control;
}

Ensure that the arguments you provide properly match your caching requirements; incorrect arguments can lead to unwanted caching behaviors.

Remember to check for caching in other parts of your configuration, such as in proxy_cache or other cache directives that may override this setting.

← Back to all directives