Opened 13 months ago

Last modified 11 months ago

#2569 closed defect

nginx serves stale 200 page which was deleted (became 404) — at Version 3

Reported by: devpets@… Owned by:
Priority: major Milestone:
Component: nginx-core Version: 1.25.x
Keywords: cache stale 404 Cc:
uname -a: Linux 3.10.0-1160.42.2.el7.x86_64
nginx -V: nginx version: nginx/1.20.1

Description (last modified by devpets@…)

Hello I've read same bugs here but they were closed so I open a new one since I believe its not logic condition.

nginx relevant config:

proxy_cache_background_update on;
proxy_cache_key                "$MOBILE$scheme$host$request_uri";
proxy_cache_lock               on;
proxy_cache_methods            GET HEAD;
proxy_cache_use_stale          timeout invalid_header updating http_429 http_500 http_502 http_503 http_504 http_403; # 

proxy_cache_valid              200 15s;
proxy_cache_valid              404 15s;

---
I create simple file 404.txt and doing curl two times:

curl https://x.x.x/404.txt -k -I
HTTP/2 200 
server: nginx
date: Sun, 26 Nov 2023 07:44:29 GMT
content-type: text/plain; charset=UTF-8
content-length: 6
x-powered-by: WP Rocket/3.10.3
cache-control: public
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-nginx-upstream-cache-status: MISS
accept-ranges: bytes

again:

HTTP/2 200 
server: nginx
date: Sun, 26 Nov 2023 07:44:31 GMT
content-type: text/plain; charset=UTF-8
content-length: 6
x-powered-by: WP Rocket/3.10.3
cache-control: public
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-nginx-upstream-cache-status: HIT
accept-ranges: bytes

As you see now the file is cached in nginx.
Now I go and remove this file from server and doing curl again 4 times:

curl https://x.x.x/404.txt -k -I
HTTP/2 200 
server: nginx
date: Sun, 26 Nov 2023 07:45:27 GMT
content-type: text/plain; charset=UTF-8
content-length: 6
x-powered-by: WP Rocket/3.10.3
cache-control: public
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-nginx-upstream-cache-status: STALE
accept-ranges: bytes

HTTP/2 200 
server: nginx
date: Sun, 26 Nov 2023 07:45:29 GMT
content-type: text/plain; charset=UTF-8
content-length: 6
x-powered-by: WP Rocket/3.10.3
cache-control: public
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-nginx-upstream-cache-status: STALE
accept-ranges: bytes

HTTP/2 200 
server: nginx
date: Sun, 26 Nov 2023 07:46:34 GMT
content-type: text/plain; charset=UTF-8
content-length: 6
x-powered-by: WP Rocket/3.10.3
cache-control: public
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-nginx-upstream-cache-status: UPDATING
accept-ranges: bytes

HTTP/2 200 
server: nginx
date: Sun, 26 Nov 2023 07:46:48 GMT
content-type: text/plain; charset=UTF-8
content-length: 6
x-powered-by: WP Rocket/3.10.3
cache-control: public
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
x-nginx-upstream-cache-status: STALE
accept-ranges: bytes

nginx log:

10.15.1.15 - STALE [26/Nov/2023:10:25:24 +0200]  "HEAD /404.txt HTTP/2.0" 200 0 "-" "curl/7.74.0"

Now it stales forever, it never refresh.
I tried to add/remove this config:

proxy_cache_valid              404 15s;

but it doesn't change the behavior.
When I manually remove all cache files from nginx or if I add cache buster i.e:

curl https://x.x.x/404.txt?1=1

it begins to return 404.

Please advise how to proceed.
Dmitry Sherman

Change History (3)

comment:1 by devpets@…, 13 months ago

Description: modified (diff)

comment:2 by devpets@…, 13 months ago

Description: modified (diff)

comment:3 by devpets@…, 13 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.