Некорректный ответ при использовании fastcgi cache background update on

gz nginx-forum на forum.nginx.org
Вс Апр 8 23:50:42 UTC 2018


Добрый вечер.

При использовании fastcgi_cache_background_update наблюдаю странное
поведение nginx.
Адрес недоступен, в кэше лежит ответ со статусом 404.

По истечении времени жизни кэша вместо обращения к апстриму и сохранения
ответа со статусом 404 в кэш и отдачи его клиенту выдаётся ответ нулевой
длины со статусом 200, который попадает в кэш.

0.0.0.0 - - [09/Apr/2018:01:31:32 +0300] "GET /missing/ HTTP/1.1" 404 3464
"-" "Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:33:32 +0300] "GET /missing/ HTTP/1.1" 404 3464
"-" "Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:35:33 +0300] "GET /missing/ HTTP/1.1" 404 3464
"-" "Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:37:32 +0300] "GET /missing/ HTTP/1.1" 404 3464
"-" "Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:37:52 +0300] "GET /missing/ HTTP/1.1" 200 0 "-"
"Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:41:32 +0300] "GET /missing/ HTTP/1.1" 200 0 "-"
"Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:43:32 +0300] "GET /missing/ HTTP/1.1" 200 0 "-"
"Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:45:32 +0300] "GET /missing/ HTTP/1.1" 200 0 "-"
"Mozilla/5.0"
0.0.0.0 - - [09/Apr/2018:01:47:33 +0300] "GET /missing/ HTTP/1.1" 200 0 "-"
"Mozilla/5.0"

Стоит отключить fastcgi_cache_background_update — проблема исчезает.

Выдержка из конфигурации.
fastcgi_cache_lock              on;
fastcgi_cache_lock_age          15s;
fastcgi_cache_use_stale         error timeout updating http_500;
fastcgi_cache_background_update on;
…
fastcgi_cache_valid             404 410 5m;

----------
Ubuntu 16.04.4 LTS

nginx version: nginx/1.13.9
built with OpenSSL 1.0.2g  1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong
-Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now
-fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf
--http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock
--pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit
--with-http_ssl_module --with-http_stub_status_module
--with-http_realip_module --with-http_auth_request_module
--with-http_v2_module --with-http_dav_module --with-http_slice_module
--with-threads --with-http_addition_module --with-http_geoip_module=dynamic
--with-http_gunzip_module --with-http_gzip_static_module
--with-http_image_filter_module=dynamic --with-http_sub_module
--with-http_xslt_module=dynamic --with-stream=dynamic
--with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module

Posted at Nginx Forum: https://forum.nginx.org/read.php?21,279350,279350#msg-279350



Подробная информация о списке рассылки nginx-ru