Opened 3 years ago

Closed 3 years ago

#2274 closed defect (duplicate)

Serving stale content, when proxy_cache_background_update is on and Cache-Control disappears

Reported by: karol-gro@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.19.x
Keywords: proxy, cache Cc: karol-gro@…
uname -a: Windows 10 Pro, 21H1, build 19043.1288
nginx -V: nginx version: nginx/1.21.3
built by cl 16.00.40219.01 for 80x86
built with OpenSSL 1.1.1l 24 Aug 2021
TLS SNI support enabled
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/ --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre-8.44 --with-zlib=objs.msvc8/lib/zlib-1.2.11 --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-openssl=objs.msvc8/lib/openssl-1.1.1l --with-openssl-opt='no-asm no-tests -D_WIN32_WINNT=0x0501' --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module


nginx for Windows

I set up nginx proxy with following config

worker_processes  1;

events {
    worker_connections  1024;

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;
	proxy_cache_path C:\\folder\\cache levels=1:2 keys_zone=my_cache:1m max_size=1g inactive=12h use_temp_path=off;

    server {
        listen       4080;
        listen       [::]:4080;
        server_name  localhost;

        location /api/ {
            proxy_http_version 1.1;
            proxy_set_header X-TenantKey SomeKey;

        location / {
            rewrite "^/([^/]*/){3}(.*)$" /$2 last ;

            proxy_http_version 1.1;

            proxy_cache my_cache;
            proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
            proxy_cache_lock on;
            proxy_cache_background_update on;

Reproduction steps:

  1. Create index.html file on blob storage with Test-1 content and Cache-Control: max-age=30
  2. Open IP:4080/a/b/c/index.html in HTTP client. It should work
  3. Change content to Test-2, keeping the Cache-Control. After some 30s you can see new content served by nginx
  4. Change content to Test-3 and remove Cache-Control header.

Expected result:
As all responses without cache-control, it will be treated as not-cachable. Background updater removes it from cache and nginx will proxy to source on each request

Actual result:
Nginx serves still an old Test-2 with cache-control, even after 2 minutes.

Change History (1)

comment:1 by Maxim Dounin, 3 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #853.

Note: See TracTickets for help on using tickets.