前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Nginx缓存清理模块ngx_cache_purge

Nginx缓存清理模块ngx_cache_purge

作者头像
行 者
发布2020-04-21 10:27:22
3.4K0
发布2020-04-21 10:27:22
举报
文章被收录于专栏:运维技术迷运维技术迷

简述

nginx_cache_purge是nginx的一个三方模块,主要是对nginx生产的缓存(proxy_cache)内容进行清理。

模块github介绍:ngx_cache_purge is nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches.

模块GITHUB链接:https://github.com/FRiCKLE/ngx_cache_purge

安装

nginx_cache_purge是一个三方模块,默认没有编译到nginx中,需要我们手动add进去。

代码语言:javascript
复制
[root@lnmp openresty-1.15.8.2]# ./configure --prefix=/usr/local --user=www --group=www --add-module=/data/software/openresty-1.15.8.2/ngx_cache_purge
[root@lnmp openresty-1.15.8.2]# gmake 
[root@lnmp openresty-1.15.8.2]# gmake install

配置

代码语言:javascript
复制
upstream svr{
    server 192.168.3.1100:8088;
}
server {
    listen  80;
    index index.html;
    server_name dev.nginx.top;

   location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://svr;
        add_header Cache-Control no-store;

        proxy_cache cache;
        proxy_cache_key    $uri$is_args$args;
        proxy_cache_valid   30m;
        add_header  X-Cache-status "$upstream_cache_status";
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_next_upstream off;
      
     }
     location ~ /purge(/.*) {
        allow        all;
        proxy_cache_purge cache $1$is_args$args;

     }

测试

在你需要删除缓存的uri前加purge就可以了。例如一个有缓存的页面是https://cloud.tencent.com/developer/article/1616198,那么删除缓存的时候使用https://www.lianst.com/purge/4030.html就可以了

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 简述
  • 安装
  • 配置
  • 测试
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档