0
$upstream_cache_status
是HIT,但$request_time
有时会持续5秒,有什么问题?
我的nginx.conf
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
client_max_body_size 30M;
proxy_temp_path /tmp/proxy_temp_dir;
proxy_cache_path /tmp/proxy_cache_dir levels=1:2 keys_zone=cache:500m inactive=1d max_size=500m;
log_format cache_log '$remote_addr - [$request_time] $status $upstream_cache_status "$request"';
server {
access_log logs/access.log cache_log;
error_log logs/error.log error;
proxy_cache cache;
proxy_cache_valid 10m;
location/{
proxy_next_upstream http_502 error timeout;
proxy_http_version 1.1;
proxy_set_header Connection "";
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_pass http://xxxxxx;
}
}
include /usr/local/openresty/nginx/conf/vhosts/*.conf;
}
而且access.log的:
x.x.x.x - [5.076] 200 HIT "GET /xxx"
x.x.x.x - [0.092] 200 HIT "GET /xxx"
相同的请求URL,两者都命中缓存,为什么$request_time
最后5秒以上?
谢谢。
它总是第一次打?我会说被调用的元素没有被缓存。 – Ota
记录'$ upstream_response_time'。它是否第一次请求该网址很长一段时间?它可能是硬盘延迟? –
@AlexeyTen所有HIT请求的$ upstream_response_time都为空。 – fannheyward