#缓存目录 目录级别 缓存池 有效时间 最大空间
proxy_cache_path /usr/
local/etc/nginx/
cache levels
=1:
2 keys_zone
=STATIC:
10m
inactive
=24h max_size
=1g;
location /get_api_post_data {
proxy_pass http:
proxy_set_header Host
$host; #header
proxy_cache_methods GET HEAD POST;
proxy_ignore_headers Cache-Control Set-Cookie; #设置客户端缓存
proxy_cache
STATIC; #缓存池
proxy_cache_valid
200 1m; #请求为
200 缓存一分钟
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
}
其中proxy_cache_key 默认为
host
uri 针对接口缓存,不会因为参数改变而不走缓存 当然也可以自己定义
proxy_cache_key
$host$uri$is_args$args; //通过key来
hash,定义KEY的值
参考文章 https://www.nginx.com/resources/wiki/start/topics/examples/reverseproxycachingexample/
转载请注明原文地址: https://ju.6miu.com/read-658521.html