nginx 反向代理设置缓存配置
proxy_cache_path /home/cache levels=1:2 keys_zone=cache_one:20m inactive=365d max_size=300g;
client_body_buffer_size 512k;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
proxy_buffer_size 32k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_cache cache_one;
proxy_cache_key "$host:$server_port$request_uri"; #对缓存的资源会设置一个key
proxy_cache_valid 200 1m; #状态码为200的缓存1分钟
add_header X-Cache $upstream_cache_status; #将缓存添加到header中 这个需要配置到站点里面
//清理缓存
location ~ /pcache/(.*){
add_header Content-Type "text/plain;charset=utf-8";
proxy_cache_purge X-Cache $1$is_args$args;
#return 200 $request_uri;
#return 200 $1$is_args$args;
allow all;
}
//参考缓存配置
proxy_temp_path /home/cache/tmp;
proxy_cache_path /home/cache levels=1:2 keys_zone=X-Cache:20m inactive=360d max_size=300g;
proxy_cache X-Cache;
#proxy_cache_key "$host:$server_port$request_uri"; #对缓存的资源会设置一个key
proxy_cache_key "$host$request_uri"; #对缓存的资源会设置一个key
proxy_cache_valid 200 360d; #状态码为200的缓存360天
#add_header cachex $upstream_cache_status; #将缓存添加到header中
client_body_buffer_size 512k;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
proxy_buffer_size 32k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!