srcache_fetch_skip

The `srcache_fetch_skip` directive specifies conditions under which subrequest caching is bypassed.

Syntaxsrcache_fetch_skip condition;
Defaultnone
Contexthttp, server, location, if in location
Arguments1

Description

The srcache_fetch_skip directive is used to control the caching behavior of subrequests in the NGINX srcache module. By defining an expression for this directive, you can designate specific conditions that, when met, will prevent caching of responses during subrequests. This directive is especially useful when response caching is undesirable under certain circumstances, such as specific query parameters or headers that might alter the response content.

The directive takes a single argument which should be a valid NGINX variable or expression. If the evaluated expression returns a truthy value, the caching mechanism will skip fetching the cache for that specific request. This is particularly useful for scenarios where you want to allow some requests to bypass the cache while letting others be cached normally.

When combined with other caching directives like srcache_fetch, srcache_store, and others, srcache_fetch_skip provides a fine-grained control over caching strategy and behavior to optimize performance while ensuring that dynamic content is appropriately handled. Proper implementation of this directive can lead to significant performance benefits by reducing the number of stale cache hits in situations where content changes are frequent and need real-time fetching from the upstream source.

Config Example

location /example {
    srcache_fetch_skip $arg_no_cache;
    srcache_fetch your-fetch-conditions;
}

Ensure that the condition evaluates correctly; errors in expression syntax can lead to unintended cache behavior.

Be cautious with the scope of variables used in the condition; ensure they are available in the context of the request.

Evaluate performance impacts of frequent cache skipping on your application, as it may lead to increased load on upstream servers.

← Back to all directives