[PATCH] Upstream: fastcgi_cache_convert_head directive.
Maxim Dounin
mdounin at mdounin.ru
Tue Jan 23 13:52:10 UTC 2018
Hello!
On Tue, Jan 23, 2018 at 03:27:23PM +0200, Gena Makhomed wrote:
> On 23.01.2018 14:32, Maxim Dounin wrote:
>
> >> # HG changeset patch
> >> # User Gena Makhomed <gmm at csdoc.com>
> >> # Date 1516650013 -7200
> >> # Mon Jan 22 21:40:13 2018 +0200
> >> # Node ID 4f635c5c8da929eb1e25bc8fbce7d7d5726468cf
> >> # Parent cbf59d483c9cd94dc0fb05f1978601d02af69c20
> >> Upstream: fastcgi_cache_convert_head directive.
> >>
> >> The directive toggles conversion of HEAD to GET for cacheable fastcgi
> >> requests.
> >> When disabled, $request_method must be added to cache key for consistency.
> >> By default, HEAD is converted to GET as before.
> >>
> >> After previous patch http://hg.nginx.org/nginx/rev/4d5ac1a31d44
> >> HEAD is not converted to GET as before for cacheable fastcgi requests.
> >>
> >> This patch fixes fastcgi cache regression introduced
> >> by patch http://hg.nginx.org/nginx/rev/4d5ac1a31d44
> >
> > Please elaborate. We aren't aware of any cache regressions
> > introduced by 4d5ac1a31d44. Also, I don't see how the change in
> > question can introduce one, or the suggested patch can fix it.
>
> By default HEAD converted to GET only for cacheable proxy requests.
>
> For cacheable fastcgi requests no such conversion is done,
> and, this is means what example for fastcgi_cache_key in documentation
> https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_key
> is invalid:
>
> fastcgi_cache_key localhost:9000$request_uri;
>
> If first request to cacheable resource was HEAD
> - nginx cache will be populated with empty response,
> and all rest GET requests will return empty page to client.
>
> This is bug. Probably nginx documentation should be fixed:
> $request_method must be included in fastcgi_cache_key example
> and nginx documentation should explicitly define, what $request_method
> always must be added to fastcgi cache key for consistency.
The documentation provides an example. Whether this example is
correct for a particular script or not - depends on the script and
other configuration. Most [Fast]CGI scripts don't care about request
method and always return response with a body, hence the example.
Note well that fastcgi_cache_key is not set by default. This is
because proper key depends on the configuration, and constructing
appropriate cache key is dedicated to the administrator.
> Second approach is to make fastcgi cache work similar to proxy cache,
> and this way I was try to do with my patch. But as I can realize later,
> my patch in not complete and HEAD not converted to GET for cacheable
> fastcgi requests. Probably I also need to switch request method
> in ngx_http_fastcgi_create_request function from fastcgi module.
Ok, so you've already realized that your patch does nothing, and
the patch description is simply wrong.
> I think, what fastcgi cache and proxy cache should work uniformly,
> by default converting HEAD to GET for cacheable fastcgi requests too.
While making fastcgi cache and proxy cache identical is certainly
a good goal, it would be something not trivial to achieve without
various major changes.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list