【问题标题】:Why Wordpress Cache plugin does't work with NGINX/PHP-FM?为什么 Wordpress 缓存插件不适用于 NGINX/PHP-FM?
【发布时间】:2018-12-05 11:53:04
【问题描述】:

子域上的 Centos7、Vestacp、Nginx/PHP-FM、WordPress 多站点。

一切正常,但我的缓存插件不起作用。 我尝试 wp-super-cache,现在我使用 Cache-Enabler 插件。 但不起作用......两天无法解决这个问题。请帮忙。

我的 nginx 模板的一部分

# CacheEnabler Start
 set $cache_uri $request_uri;

# bypass cache if POST requests or URLs with a query string
if ($request_method = POST) {
    set $cache_uri 'nullcache';
}
if ($query_string != "") {
    set $cache_uri 'nullcache';
}

# bypass cache if URLs containing the following strings
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
    set $cache_uri 'nullcache';
}

# bypass cache if the cookies containing the following strings
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
    set $cache_uri 'nullcache';
}
# default html file
set $cache_enabler_uri '/wp-content/cache/cache-enabler/${http_host}${cache_uri}index.html';    

location / {
try_files $cache_enabler_uri $uri $uri/ /index.php?$args;

    if (!-e $request_filename)
    {
        rewrite ^(.+)$ /index.php?q=$1 last;
    }

    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
        expires     max;
    }

    location ~ [^/]\.php(/|$) {

    fastcgi_buffers 8 256k;
    fastcgi_buffer_size 128k;
    fastcgi_intercept_errors on;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    fastcgi_cache microcache;
    fastcgi_cache_key $scheme$host$request_uri$request_method;
    fastcgi_cache_valid 200 301 302 30s;
    fastcgi_cache_use_stale updating error timeout invalid_header http_500;
    fastcgi_pass_header Set-Cookie;
    fastcgi_pass_header Cookie;
    fastcgi_ignore_headers Cache-Control Expires Set-Cookie;   

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        if (!-f $document_root$fastcgi_script_name) {
            return  404;
        }

        fastcgi_pass    %backend_lsnr%;
        fastcgi_index   index.php;
        include         /etc/nginx/fastcgi_params;
    }
}

location /error/ {
    alias   %home%/%user%/web/%domain%/document_errors/;
}
include     %home%/%user%/conf/web/nginx.%domain_idn%.conf*;

【问题讨论】:

  • 我的 nginx.conf 的一部分 open_file_cache max=10000 inactive=30s; open_file_cache_valid 60s; open_file_cache_min_uses 2; open_file_cache_errors off; fastcgi_cache_path /var/cache/nginx/fcgi levels=1:2 keys_zone=microcache:10m max_size=1024m inactive=1h;

标签: wordpress nginx


【解决方案1】:

我尝试了 Breeze 插件,安装后即可使用。

WpSupercache,缓存启动器,litespeed,不起作用(多站点,子域,nginx+php-fpm)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-31
    • 1970-01-01
    • 1970-01-01
    • 2016-10-02
    • 2018-06-21
    • 2017-07-28
    相关资源
    最近更新 更多