uwsgi_cache_bypass

The uwsgi_cache_bypass directive controls conditions under which caching is skipped for uWSGI responses.

Syntaxuwsgi_cache_bypass condition | condition ...;
Defaultnone
Contexthttp, server, location
Arguments1+

Description

The uwsgi_cache_bypass directive in NGINX is utilized to dictate specific conditions that result in the bypassing of a cached uWSGI response. This is particularly useful in scenarios where certain requests should not retrieve cached content, ensuring that the most current data can be served without caching interference. You can specify one or more parameters for the directive, which can be user-defined variables or conditions based on HTTP headers or other request attributes.

The directive can be placed in the http, server, or location contexts and supports one or more arguments. Each argument represents a condition or variable that, when evaluated to true, will trigger the caching system to bypass the cached response for the request. For instance, you might configure uwsgi_cache_bypass to avoid caching for authenticated users or when specific query parameters are present in the request.

Additionally, this directive works in tandem with other cache-related directives like uwsgi_cache and uwsgi_cache_key. Properly using uwsgi_cache_bypass alongside these directives can fine-tune the caching behavior in a way that best meets your application's needs, allowing developers to control when cache should not be used, thus providing more dynamic content delivery.

Config Example

location /api {
    uwsgi_pass backend;
    uwsgi_cache my_cache;
    uwsgi_cache_bypass $arg_bypass;
}

Ensure that any condition you specify actually evaluates to true to bypass the cache; otherwise, caching will occur.

Using too many conditions may lead to performance degradations if not managed correctly, as it adds overhead to request processing.

← Back to all directives