我在nginx 中有一个页面如下
location = /page {
proxy_pass http://localhost:82;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header Set-Cookie;
access_log off;
add_header Cache-Control public;
add_header X-Cache-Status $upstream_cache_status
proxy_cache page;
proxy_cache_key backend$request_uri;
proxy_cache_valid 200 302 100d;
proxy_cache_valid 404 1m;
proxy_cache_use_stale error timeout invalid_header;
}
Run Code Online (Sandbox Code Playgroud)
使用缓存设置如下
proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=page:10m inactive=7d max_size=50m;
Run Code Online (Sandbox Code Playgroud)
但是这个页面总是返回一个miss

可能有什么问题?
kol*_*ack 11
如果您的后端响应具有 Set-Cookie 标头,则需要proxy_ignore_headers Set-Cookie;而不是 proxy_hide_header Set-Cookie;
| 归档时间: |
|
| 查看次数: |
9231 次 |
| 最近记录: |