Welcome! Log In Create A New Profile


proxy_cache_bypass inheritance bug?

March 21, 2023 01:15PM
I think I've found a bug (or I've just been staring at code too long) regarding proxy_cache_bypass and possibly proxy_no_cache.

Essentially my config is something like this below. At the top server level caching only occurs for guests (no userid cookie set), while connections that have a userid cookie set get bypassed (and also it won't save those requests to a cache). I have a specific folder (let's call it "stuff") that I want cached regardless and it is using a separate cache zone.

I've tried to set proxy_cache_bypass with a 0, with just quotes "", quotes with a space " ", and nothing seems to work. It's acting like it's inheriting the upstream settings (as tested by querying without the cookie userid set vs unset) because it will cache only if if the userid cookie is not set.

Am I missing something obvious? I thought lower-level settings always overwrote higher level ones?

server {
add_header X-Cache-Status $upstream_cache_status;

# Cache upstream responses short-term.
proxy_cache main_cache;
proxy_ignore_headers Set-Cookie;

# Skip caching for registered users and certain directories.
proxy_cache_bypass $skip_directories $cookie_userid;
proxy_no_cache $skip_directories $cookie_userid;

# Cache this directory for 1 week in separate cache for everyone.
location ^~ /stuff/ {
proxy_cache longer_cache;
proxy_cache_bypass 0;
proxy_no_cache 0;
try_files _ @proxy;
Subject Author Posted

proxy_cache_bypass inheritance bug?

Jas0n March 21, 2023 01:15PM

Re: proxy_cache_bypass inheritance bug?

Jas0n March 23, 2023 12:30PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 252
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready