nginx with proxy_cache_use_stale not returning from cache when connection refused

new299 nginx-forum at
Thu Dec 11 15:14:20 UTC 2014

Thanks, I've tried this. My amended configuration is below. However, I'm
still getting the same error when the upstream goes away. The cache
directory is now being populated correctly however. Any ideas?


user www-data;
worker_processes 4;
pid /run/;

events {
        worker_connections 768;
        # multi_accept on;

http {
        upstream localsvr {
                server localhost:8080;

        proxy_cache_path  /data/nginx/cache levels=1:2 keys_zone=one:8m
max_size=5000m inactive=300m;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        server {
                keepalive_timeout 65;
                types_hash_max_size 2048;
                proxy_buffering on;

                default_type application/octet-stream;

                gzip on;
                gzip_disable "msie6";
                listen 80;
                proxy_cache one;
                proxy_cache_min_uses 1;
                proxy_cache_valid 200 302 10m;
                proxy_cache_valid any      10m;
                proxy_set_header Host $host;
                location / {
                        proxy_pass http://localsvr;
                        proxy_cache_use_stale error;
                        proxy_next_upstream error;
                        proxy_redirect off;

Posted at Nginx Forum:,255408,255440#msg-255440

More information about the nginx mailing list