添加配置
nginx.conf添加缓存配置
proxy_cache_path /data/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
nginx 子配置文件中引用配置
location ~ .*\.(gif|jpg|png|htm|html|css|js|flv|ico|swf)(.*) {
proxy_pass https://huhuhahei.cn;
proxy_redirect off;
proxy_cache cache_one;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 301 1d;
proxy_cache_valid any 1m;
include conf.d/steam_sub_filter.conf;
expires 30d;
}
配置完成重启nginx
nginx -s reload
查看缓存目录是否有生成文件
ll cache/
total 100
drwx------ 18 nobody root 150 Mar 26 16:00 ./
drwxr-xr-x 5 root root 48 Apr 11 11:27 ../
drwx------ 167 nobody nogroup 4096 Apr 20 14:21 0/
drwx------ 171 nobody nogroup 4096 Apr 20 14:20 1/
drwx------ 157 nobody nogroup 4096 Apr 20 10:55 2/
drwx------ 165 nobody nogroup 4096 Apr 20 10:55 3/
drwx------ 177 nobody nogroup 4096 Apr 20 11:33 4/
drwx------ 170 nobody nogroup 4096 Apr 20 14:21 5/
drwx------ 176 nobody nogroup 4096 Apr 20 14:21 6/
drwx------ 163 nobody nogroup 4096 Apr 20 07:14 7/
drwx------ 169 nobody nogroup 4096 Apr 20 04:22 8/
drwx------ 162 nobody nogroup 4096 Apr 20 14:21 9/
drwx------ 164 nobody nogroup 4096 Apr 20 14:20 a/
drwx------ 174 nobody nogroup 4096 Apr 20 11:33 b/
drwx------ 180 nobody nogroup 4096 Apr 20 10:55 c/
drwx------ 179 nobody nogroup 4096 Apr 20 14:20 d/
drwx------ 160 nobody nogroup 4096 Apr 20 10:15 e/
drwx------ 169 nobody nogroup 4096 Apr 20 10:58 f
文件正常生成 证明缓存配置已经生效