bypassing and replacing cache if origin changed - or purging cache when origin changed?

nenaB nginx-forum at
Fri Jan 25 20:28:42 UTC 2019

I have nginx configured to cache certain requests mapped by
tenant/host/uri/args - these files wouldn't change often, but if they do, i
want nginx to fetch them new.

I don't have NginxPlus - and I'm running Nginx docker.  Some things that I
have investigated, but not sure how I could configure to make it work is: 
the proxy_cache_bypass and the expires settings.

But I'm not sure about whether something like:  expires
$upstream_http_expires 1d; would work?  If it checks upstream every time, it
would defeat the purpose of caching.  What exactly do I need to configure if
I want to test whether for a given cache-key on the upstream server, is
there new content? (I can implement an api that could test whether new
content is available.)

Another option is to implement a fastcgi script that would test the upstream
api and purge the cache based on that, but I'm hoping that I can leverage
the power of Nginx rather than having an additional script to maintain. 
Thanks in advance.

Posted at Nginx Forum:,282833,282833#msg-282833

More information about the nginx mailing list