NGinx需要很长时间才能从缓存中获取内容。请查看下面的日志。
84.210.206.210 - - [04/Oct/2018:13:24:55 +0000] "GET /mdp/show/574e46822e853fa0f380f1e3/groupid%3A%2F%2F650183866?pset=mdp%3Ano-presentation&filter%3AfirstRun=false HTTP/1.1" 200 23059 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_05)" cachestatus: HIT dest: - response_time: 13.003
84.210.206.210 - - [04/Oct/2018:13:24:55 +0000] "GET /mdp/show/574e46822e853fa0f380f1e3/groupid%3A%2F%2F650183866?pset=mdp%3Ano-presentation&filter%3AfirstRun=false HTTP/1.1" 200 16219 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_05)" cachestatus: HIT dest: - response_time: 51.513
84.210.206.210 - - [04/Oct/2018:13:24:55 +0000] "GET /mdp/show/574e46822e853fa0f380f1e3/groupid%3A%2F%2F650183866?pset=mdp%3Ano-presentation&filter%3AfirstRun=false HTTP/1.1" 200 1403792 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_05)" cachestatus: HIT dest: - response_time: 3.513
84.210.206.210 - - [04/Oct/2018:13:24:55 +0000] "GET /mdp/show/574e46822e853fa0f380f1e3/groupid%3A%2F%2F650183866?pset=mdp%3Ano-presentation&filter%3AfirstRun=false HTTP/1.1" 200 18955 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_05)" cachestatus: HIT dest: - response_time: 42.008
84.210.206.210 - - [04/Oct/2018:13:24:55 +0000] "GET /mdp/show/574e46822e853fa0f380f1e3/groupid%3A%2F%2F650183866?pset=mdp%3Ano-presentation&filter%3AfirstRun=false HTTP/1.1" 200 28531 "-" "Apache-HttpClient/4.5.2 (Java/1.8.0_05)" cachestatus: HIT dest: - response_time: 23.008
很少有人花50秒钟。我不确定为什么会这样。 我的配置如下。
proxy_cache_path /var/cache/nginx/mdp_cache levels=1:2 keys_zone=mdp_cache:128m max_size=5g loader_threshold=300 loader_files=200 inactive=120m;
location ~ /mdp/show/(.*) {
proxy_pass http://mdp;
proxy_cache mdp_cache;
proxy_cache_lock on;
proxy_cache_lock_age 60s;
proxy_cache_lock_timeout 60s;
proxy_read_timeout 60000ms;
proxy_http_version 1.1;
proxy_set_header Connection "";
#proxy_ignore_headers Cache-Control;
#proxy_ignore_headers Expires;
#proxy_cache_revalidate on;
proxy_cache_min_uses 1;#minimum number of resquests to be hit before getting cached
proxy_cache_valid 404 0s;
proxy_cache_valid 200 201 202 203 204 304 240m;#200 201 202 203 204 http cached response is valid for 120 min
proxy_cache_valid 502 504 0s;#dont cache 502, 504 responses
add_header X-Proxy-Cache $upstream_cache_status;#To figure out if the response was from cache or not
add_header X-Proxy-GRID T4;
}
知道我在做什么错吗?