系统相关
首页 > 系统相关> > 14 nginx 配置缓存

14 nginx 配置缓存

作者:互联网

1 开启缓存,二级目录

 # 开启缓存,二级目录
    proxy_cache_path /usr/local/nginx/proxy_cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=20g;
    proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
    proxy_hide_header Cache-Control;
    proxy_hide_header Pragma;

2 静态文件加缓存

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|ico)?$
        {
            expires 1d;
            proxy_cache cache_one;
            proxy_cache_valid 200 304 1d;
            proxy_cache_valid any 1m;
            proxy_cache_key $host$uri$is_args$args;
            proxy_pass http://server_pool;
        }

3 清除缓存

 # 清除缓存
    location ~ /purge(/.*)
        {
            allow 127.0.0.1;
            allow 10.23.23.25;            allow 10.23.23.33;
            deny all;
            proxy_cache_purge cache_one $host$1$is_args$args;
        }

标签:缓存,14,args,cache,nginx,proxy,allow,1d
来源: https://www.cnblogs.com/weidalin/p/14995057.html