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