Syntax: | uwsgi_cache_valid [ |
---|---|
Default: | — |
Context: | http , server , location |
Sets caching time for different response codes. For example, the following directives
uwsgi_cache_valid 200 302 10m; uwsgi_cache_valid 404 1m;
set 10 minutes of caching for responses with codes 200 and 302 and 1 minute for responses with code 404.
If only caching time
is specified
uwsgi_cache_valid 5m;
then only 200, 301, and 302 responses are cached.
In addition, the any
parameter can be specified to cache any responses:
uwsgi_cache_valid 200 302 10m; uwsgi_cache_valid 301 1h; uwsgi_cache_valid any 1m;
Parameters of caching can also be set directly in the response header. This has higher priority than setting of caching time using the directive.
- The “X-Accel-Expires” header field sets caching time of a response in seconds. The zero value disables caching for a response. If the value starts with the
@
prefix, it sets an absolute time in seconds since Epoch, up to which the response may be cached. - If the header does not include the “X-Accel-Expires” field, parameters of caching may be set in the header fields “Expires” or “Cache-Control”.
- If the header includes the “Set-Cookie” field, such a response will not be cached.
- If the header includes the “Vary” field with the special value “
*
”, such a response will not be cached (1.7.7). If the header includes the “Vary” field with another value, such a response will be cached taking into account the corresponding request header fields (1.7.7).
Processing of one or more of these response header fields can be disabled using the uwsgi_ignore_headers directive.
Please login to continue.