Proxy Cache - How to Always Return Stale Content

37 views
Skip to first unread message

Nati Ziv

unread,
Jan 15, 2018, 6:35:22 AM1/15/18
to openresty-en
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)

tokers

unread,
Jan 15, 2018, 8:54:28 PM1/15/18
to openresty-en
Hello!

It seems that there no way to achieve this unless hacks the source code(e.g. add some extra ft_type for upstream cache).
Reply all
Reply to author
Forward
0 new messages