【问题标题】:What is actual ways Nginx purge cache with wildcard HTTP request?Nginx 使用通配符 HTTP 请求清除缓存的实际方法是什么?
【发布时间】:2019-04-05 14:39:38
【问题描述】:

首先我搜索并尝试了一些文章:

1) https://www.ryadel.com/en/nginx-purge-proxy-cache-delete-invalidate-linux-centos-7/

第一种方式:

a) 通过 curl 请求(BYPASS)更新缓存,它适用于我,但没有通过通配符更新缓存的示例

b) 使用PURGE方法通过curl请求删除缓存,使用过时的模块ngx_cache_purge-2.3,但是通配符上没有更新缓存的例子,至少文章中配置的不适用我(nginx 1.14):

curl -X PURGE -I mysite.com/text.txt

curl: (52) 来自服务器的空回复

2) https://scene-si.org/2016/11/02/purging-cached-items-from-nginx-with-lua/; https://gist.github.com/titpetric/2f142e89eaa0f36ba4e4383b16d61474/revisions

第二种方式:

如果我理解正确的话,lua 需要 nginx 版本 1.10,而我的是 v1.14 并且 v.1.14 没有 lua 模块。

nginx: [emerg] 模块 "/usr/lib64/nginx/modules/ngx_http_lua_module.so" 版本 1010001 而不是 /etc/nginx/nginx.conf:1 中的 1014000

所以我的问题是:Nginx v1.14 清除缓存使用通配符 HTTP 请求是否有可行的方法,您可以提供建议吗?

最好的问候

【问题讨论】:

    标签: nginx caching lua webserver cache-control


    【解决方案1】:

    我知道这个问题有点老了。但我目前正在使用这个 lua 模块,它允许通配符:https://github.com/diego-treitos/nginx_cache_multipurge

    它有安装和使用它的所有说明。

    【讨论】:

      【解决方案2】:

      你应该如下添加PURGE,然后问题就解决了。

      if ($request_method !~ ^(GET|HEAD|POST|PURGE)$ ) {
              return 444;
      }
      

      【讨论】:

        猜你喜欢
        • 2014-08-22
        • 1970-01-01
        • 1970-01-01
        • 2011-12-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-03
        相关资源
        最近更新 更多