Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Upstream: fastcgi_cache_convert_head directive.

Maxim Dounin
January 23, 2018 08:54AM
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@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/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Upstream: fastcgi_cache_convert_head directive.

Gena Makhomed 688 January 22, 2018 02:46PM

Re: [PATCH] Upstream: fastcgi_cache_convert_head directive.

Maxim Dounin 228 January 23, 2018 07:34AM

Re: [PATCH] Upstream: fastcgi_cache_convert_head directive.

Gena Makhomed 249 January 23, 2018 08:28AM

Re: [PATCH] Upstream: fastcgi_cache_convert_head directive.

Maxim Dounin 277 January 23, 2018 08:54AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 117
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready