[PATCH] Upstream: fastcgi_cache_convert_head directive.

Gena Makhomed gmm at csdoc.com
Tue Jan 23 13:27:23 UTC 2018


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.

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.

I think, what fastcgi cache and proxy cache should work uniformly,
by default converting HEAD to GET for cacheable fastcgi requests too.

-- 
Best regards,
  Gena


More information about the nginx-devel mailing list