﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
1801	Stale cache is not updated after some time	patrick.clara@…		"I configured a reverse caching proxy which makes use of ""proxy_cache_use_stale updating"" and ""proxy_cache_background_update on"".

At first everything seems to work fine, after some time (the day after) i notice that stale caches are not updated.

This is what happens until it works fine:
1. Client makes the 1. request.
2. Proxy responds with an updated response from the upstream server and ""x-cache-status: MISS"".
3. Client makes the 2. request.
4. Proxy responds with a cached response and ""x-cache-status: HIT"".
5. Client waits 10 min. for the cache to expire and makes the 3. request.
6. Proxy responds with a cached (and slightly outdated) response and ""x-cache-status: STALE"".
7. Proxy is making a request to the upstream server.
8. Client makes the 4. request.
9. Proxy responds with a cached (and up to date) response and ""x-cache-status: HIT"".

After some time, apparently without any changes to the system, the cache breaks:
1. Client makes the 1. request.
2. Proxy responds with a cached (and outdated) response and ""x-cache-status: STALE"".
3. Proxy is making a request to the upstream server.
4. Client makes the 2. request.
5. Proxy responds with a cached (and outdated) response and ""x-cache-status: STALE"".
6. Proxy is making a request to the upstream server.
7. Repeats forever.

At the moment I can not tell exactly how much time it needs to pass for the cache to break. Up to now i noticed a broken cache on the day after. Also I do not know if there is a correlation with the number and time of the requests being made in the meantime.

I attached the nginx configuration and two debug logs of the cache updating fine and not updating.

ps: the upstream server add ""x-accel-expire: 600"" to the response."	defect	closed	minor		nginx-core	1.14.x	invalid			Linux webc-g1 4.19.0-0.bpo.5-amd64 #1 SMP Debian 4.19.37-3~bpo9+1 (2019-05-18) x86_64 GNU/Linux	"nginx version: nginx/1.14.1
built with OpenSSL 1.1.0f  25 May 2017 (running with OpenSSL 1.1.1b  26 Feb 2019)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-jqo7Nx/nginx-1.14.1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-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_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-headers-more-filter --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-auth-pam --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-cache-purge --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-dav-ext --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-ndk --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-echo --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-fancyindex --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/nchan --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-lua --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/rtmp --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-uploadprogress --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-upstream-fair --add-dynamic-module=/build/nginx-jqo7Nx/nginx-1.14.1/debian/modules/http-subs-filter"
