Welcome! Log In Create A New Profile

Advanced

proxy_cache_bypass and non-200 response

Grzegorz Kulewski
September 26, 2017 12:16PM
Hello,

I think I found a bug or undocumented feature in nginx. Or it's just me being stupid.

I am debugging the following case:
1. I have an upstream that sometimes returns HTTP 200 and sometimes returns HTTP 401 and both codes are OK from my point of view. Both are returned with X-Accel-Expires allowing for caching.
2. I have an nginx caching proxy server that uses that upstream and caches the responses. It also changes 401 to 403 using error_page.
3. Now if there is cache MISS for the URL and upstream returns 401 it gets cached by nginx correctly.
4. But if there is already HTTP 200 response in the cache and the request bypasses the cache and the upstream returns 401, the cache seems to ignore 401 and keeps old HTTP 200 response.

This makes it impossible to re-cache HTTP 200 response with a newer (401 but still newer) response.

Possibly same problem applies to other non-200 responses but right now only 401 interests me.

I am not using any directives like proxy_cache_use_stale or similar. Only proxy_pass, proxy_cache and proxy_cache_bypass. I set proxy_cache_key to $remote_addr. I am using nginx version 1.12.1 from your Ubuntu xenial repository.

--
Grzegorz Kulewski

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

proxy_cache_bypass and non-200 response

Grzegorz Kulewski September 26, 2017 12:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 149
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready