[PATCH] Allow 1xx 2xx 3xx 4xx 5xx codes in xxxxx_cache_valid directives.
Maxim Dounin
mdounin at mdounin.ru
Fri Sep 21 12:58:39 UTC 2018
Hello!
On Fri, Sep 21, 2018 at 02:24:49PM +0300, Gena Makhomed wrote:
> # HG changeset patch
> # User Gena Makhomed <gmm at csdoc.com>
> # Date 1537528104 -10800
> # Fri Sep 21 14:08:24 2018 +0300
> # Node ID a7533f3f3138fe5524a0f14293da4149e65b1402
> # Parent 87d2ea860f380dc8418c97c0163412f53c2d008e
> Allow 1xx 2xx 3xx 4xx 5xx codes in xxxxx_cache_valid directives.
>
> For example, config fragment
>
> fastcgi_cache_valid 200 201 202 203 204 205 206 207 208 226 5m;
> fastcgi_cache_valid 300 301 302 303 304 305 306 307 308 10m;
>
> now can be rewritten as
>
> fastcgi_cache_valid 2xx 5m;
> fastcgi_cache_valid 3xx 10m;
I cannot say I like this change. Cacheability of various response
codes vary widely, and caching then "in bulk" in most cases is a
bad idea.
In particular, caching of 201 is always wrong as it is only
expected to be returned to non-cacheable POST and PUT requests.
Caching 206 is wrong unless you use "Ranges" in the cache key.
And caching 304 is wrong unless you've laso included
If-Modified-Since and If-None-Match headers in the cache key.
As such, I would rather refrain from introducing these shortcuts,
as they looks rather dangerous for the unwary.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list