[英]Nginx proxy_cache miss if URI has slash
我的 nginx 位置塊是:
location ^~ /get/preview {
add_header X-Proxy-Cache $upstream_cache_status;
proxy_buffering on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_ignore_headers Cache-Control Set-Cookie;
proxy_ssl_protocols TLSv1.3;
proxy_ssl_session_reuse on;
proxy_cache upstream;
proxy_cache_key $scheme$host$uri$is_args$args;
proxy_cache_methods GET HEAD;
proxy_cache_min_uses 0;
proxy_cache_valid 200 301 302 1h;
proxy_cache_use_stale updating;
proxy_cache_background_update on;
proxy_cache_lock on;
proxy_pass https://tar.backend.com;
}
這將是第一個請求后的HIT :
https://example.com/get/preview?fileId=17389&x=256&y=256&a=true&v=5fe320ede1bb5
這總是一個MISS :
您應該從上游檢查“過期”header。 文檔說“緩存參數可以在 header 字段“過期”或“緩存控制”中設置。
另一個選項 - 也許您有另一個位置用於具有不同選項的 .(png|jpg|css|js)$ 文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.