fastcgi_no_cache

The `fastcgi_no_cache` directive controls whether to cache responses from FastCGI applications based on specified conditions.

Syntaxfastcgi_no_cache condition | variable_names;
Defaultnone
Contexthttp, server, location
Arguments1+

Description

The fastcgi_no_cache directive is utilized to instruct NGINX whether or not to cache responses from FastCGI servers, such as PHP processors. This directive accepts one or more variables or conditions that dictate caching preferences. For example, if the value of a given variable is true, NGINX does not cache the response, enabling dynamic content generation without slowdowns caused by cache hits. It works in conjunction with the fastcgi_cache_bypass directive for consistent caching behavior based on similar conditions.

The directive must be set within the http, server, or location context of the NGINX configuration file and is typically paired with caching settings to achieve optimal performance. It's particularly useful in applications where cache invalidation is needed under specific circumstances, such as when a user is logged in, or the response content varies significantly based on request parameters. By managing dynamic content effectively, fastcgi_no_cache helps maintain the freshness of application data and improves user experience in web applications.

Config Example

location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_no_cache $http_cache_control;
}

Ensure the conditions for caching are well defined to avoid unnecessary loads on the FastCGI server.

Using incorrect variable names can result in unexpected caching behavior or incorrect responses.

← Back to all directives