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

2019-10-17 20:37:31丽君

 上面我的编译显示有 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” 部分。