如果我向配置为缓存上游的 Nginx 代理服务器发出请求,我会收到以下响应标头:
{'content-length': '13200000', 'x-cache-status': 'MISS', 'server': 'nginx/1.9.9', 'connection': 'keep-alive', 'cache-control': 'max-age=45', 'date': 'Fri, 27 Jan 2017 10:57:55 GMT'}
Run Code Online (Sandbox Code Playgroud)
几秒钟后,我再次执行相同的请求,得到以下标头:
{'content-length': '13200000', 'x-cache-status': 'HIT', 'server': 'nginx/1.9.9', 'connection': 'keep-alive', 'cache-control': 'max-age=45', 'date': 'Fri, 27 Jan 2017 10:58:18 GMT'}
Run Code Online (Sandbox Code Playgroud)
上游服务器将 max-age 标头指定为 45 秒,第二个响应标头不应该具有更新的 max-age 标头吗?那是 max-age=45-(请求之间的时间)?
编辑
重现行为的示例配置:
http {
include mime.types;
default_type application/octet-stream;
upstream backend {
server localhost:8080;
}
proxy_cache_path /etc/nginx/wwwroot/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_cache my_cache;
add_header X-Cache-Status …
Run Code Online (Sandbox Code Playgroud)