当前位置 主页 > 服务器问题 > nginx问题汇总 >

    总结Nginx 的使用过程中遇到的问题及解决方案(2)

    栏目:nginx问题汇总 时间:2018-10-20 16:35


     上面我的编译显示有 puerge 模块,是因为我已经编译过了,然后在原有的编译参数后面加上:
    复制代码 代码如下:
    --add-module=/home/ngx_cache_purge-1.5

     退出 Nginx ,并重新启动:
    复制代码 代码如下:
    ./nginx -s quit
    ./nginx

     配置 Puerge :
    复制代码 代码如下:
    location ~ /purge(/.*)
           {
            #设置只允许指定的IP或IP段才可以清除URL缓存。
            allow            127.0.0.1;
            deny             all;
            proxy_cache_purge    cache_go   $host$1$is_args$args;
           }

     清楚 Nginx 缓存的方式,比如你的 url 是 http://test.com/test/test.js
     那清除该 js 缓存的命令即为:
    复制代码 代码如下:
    curl http://test.com/purge/test/test.js

     通用的方式就是:
    复制代码 代码如下:
    curl http://test.com/purge/uri

     其中 uri 就是你的 URL “http://test.com/test/test.js” 的 “test/test.js” 部分。