为什么Nginx不缓存404响应?

时间:2019-10-22 20:15:05

标签: nginx reverse-proxy

我有此配置,但是目录上没有带有404缓存的文件 200已正确缓存

proxy_cache_path  "%hostdir%/cache/liveapi" levels=1:2 keys_zone=liveapi:10m max_size=10g use_temp_path=off;

server {
    proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
    proxy_cache_background_update on;
    proxy_ignore_headers "Expires" "Cache-Control" "Set-Cookie";
    proxy_hide_header "Set-Cookie";
    proxy_cache_lock on;
    proxy_buffering on;

    listen       127.0.0.1:5001;

    location ^~ /api/ {
        proxy_cache liveapi;
        proxy_cache_valid 200 500 6h;
        proxy_pass   http://127.0.0.1:5000;
    }
    location ^~ /api/Leagues {
        proxy_cache liveapi;
        proxy_cache_valid 200 12h;
        proxy_pass   http://127.0.0.1:5000;
    }
    location ^~ /api/LiveUpdates {
        proxy_cache liveapi;
        proxy_cache_valid 200 10s;
        proxy_pass   http://127.0.0.1:5000;
    }
    location ^~ /api/LiveUpdates/([0-9]+) {
        proxy_cache liveapi;
        proxy_cache_valid 200 10s;
        proxy_cache_valid 404 1h;
        proxy_pass   http://127.0.0.1:5000;
    }
}

^〜/ api / LiveUpdates /([0-9] +) proxy_cache_valid 404 1小时; -有用于404缓存的配置,但它不会将任何文件扔到目录中

0 个答案:

没有答案