Nginx + Fastcgi 缓存 - 清除 WordPress

问题描述 投票:0回答:1

我们使用带有 Debian 的 VPS、Nginx 1.24 + PHP-FPM 8.3 以及活跃的 Fastcgi 缓存。 一切正常,但如果我们想从 Wordpress 中清除缓存,它只会删除缓存文件,而不是文件夹。 我们在 WordPress 中使用 Nginx Helper 。使用以前的(且不受支持的)插件 Nginx Cache,我们没有问题 - 删除带有文件夹的缓存。

该插件需要ngx_cache_purge模块,但在1.24版本中不支持,但清除缓存是有效的。可能1.24版本已经集成了类似的功能。

有人遇到过这个问题吗?

虚拟主机配置文件:

fastcgi_cache_path /var/cache/nginx-cache/brainya levels=1:2 keys_zone=brainya:50m inactive=10m;

location ~ \.php$ {
          fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        include snippets/fastcgi-php.conf;
        fastcgi_cache brainya;
        fastcgi_cache_valid 200 301 302 2h;
        fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
        fastcgi_cache_min_uses 1;
        fastcgi_cache_lock on;
        fastcgi_cache_bypass $no_cache;
        fastcgi_no_cache $no_cache;
        add_header X-FastCGI-Cache $upstream_cache_status;

Nginx 助手设置 文件夹

我们尝试了 Nginx 1.22 版本,更改 fastcgi 设置、文件夹和文件的权限

wordpress nginx caching fastcgi
1个回答
0
投票

听起来您遇到了Nginx Helper插件无法清除FastCGI缓存文件夹的问题,因为它依赖于ngx_cache_purge模块,较新的Nginx版本可能不完全支持该模块。这种额外的模块依赖性有时会导致 WordPress 上的缓存管理变得复杂。

或者,Nginx FastCGI 缓存清除和预加载 (NPP) 插件提供了独特的解决方案。 NPP 不依赖外部 Nginx 模块,而是利用服务器端方法,涉及 inotifywaitsetfacl 等 Linux 工具,并通过插件作者预先制作的 bash 脚本 来实现。此方法自动从Nginx缓存目录PHP-FPM-USER授予写入权限,确保高效的缓存清除和预加载,而无需外部Nginx模块依赖。

© www.soinside.com 2019 - 2024. All rights reserved.