• Nginx 用最快方式让缓存失效


    103

    一般让及时缓存失效针对nginx官方是收费的 我们可以用第三方模块 https://github.com/FRiCKLE/ngx_cache_purge

    proxy_cache_path /data/nginx/tmpcache levels=2:2 keys_zone=two:10m loader_threshold=300 
                         loader_files=200 max_size=200m inactive=1m;
    
    server {
        server_name shop**.com.cn;
      listen : 8080;
        root html/;
        error_log logs/cacherr.log debug;
    
        location ~ /purge(/.*) {
                proxy_cache_purge two $scheme$1; #这个第三方模块key必须与下面的location 里的 proxy_cache_key一致,用于实时清除下面的key缓存
            }   
    
        location /{
            proxy_cache two;
            proxy_cache_valid 200 1m;
            add_header X-Cache-Status $upstream_cache_status;
    
            proxy_cache_key $scheme$uri;
            proxy_pass http://localhost:8012;
        }
    }

     然后先访问 crul http://shop**.com.cn:8080/purge/1.txt -I 

  • 相关阅读:
    2019 ICPC Universidad Nacional de Colombia Programming Contest
    AcWing
    模板
    AcWing
    AcWing
    AcWing
    模板
    模板
    自考新教材-p340
    自考新教材-p339
  • 原文地址:https://www.cnblogs.com/jackey2015/p/10504832.html
Copyright © 2020-2023  润新知