uwsgi_cache_methods

The uwsgi_cache_methods directive sets which HTTP methods should be cached by the uWSGI cache.

Syntaxuwsgi_cache_methods method1 [method2 ...];
DefaultGET HEAD
Contexthttp, server, location
Arguments1+

Description

The uwsgi_cache_methods directive is part of the uWSGI caching mechanism in NGINX, which allows users to specify specific HTTP methods to cache responses. By default, caching is applied only to GET and HEAD requests, but with this directive, additional methods can be included by specifying them as arguments. This flexibility is important in applications where POST or other methods yield responses that should also be cached to improve performance without excessive server load.

The directive allows one or more arguments, which are the method names such as 'GET', 'HEAD', 'POST', etc. These are case-sensitive and should be spelled correctly to be effective. In addition to controlling which methods can be cached, it provides a way to fine-tune cache behavior in line with the application's characteristics, balancing between speed and the freshness of data provided to users. After specifying the cache methods, NGINX will only cache responses generated for those HTTP methods as defined by this directive, while responses for other methods will not be stored in the cache.

The context in which this directive can be used includes http, server, and location. This flexibility means that caching can be finely controlled on a per-deployment basis, allowing administrators to customize the caching behavior based on specific circumstances.

Config Example

uwsgi_cache_methods POST PUT;

Ensure that the methods listed are valid and needed for your application; improper method specification can lead to caching issues.

Remember that the behavior of caching can also be affected by other directives such as uwsgi_cache_bypass and uwsgi_cache_use_stale.

← Back to all directives