Welcome! Log In Create A New Profile

Advanced

Proxy Cache - How to Always Return Stale Content

Posted by natiz 
Proxy Cache - How to Always Return Stale Content
January 15, 2018 06:33AM
Hello,

My use case is simple:
1) Serve static files coming from an upstream (using proxy_pass)
2) If the upstream returns a non-200/304 response - ALWAYS serve the file from cache, even if its expired/stale.

For the most part, 'proxy_cache_use_stale' does the trick.
However - it doesn't cover cases such as 401, 402, etc. (the full list it does support according to the docs: error | timeout | invalid_header | updating | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | http_429)

Is there a way I can achieve this? how can I force the file being served cache for the cases not covered by the 'proxy_cache_use_stale' directive? (even if it requires using lua)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 151
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