strange problem in Wordpress5.3, the cache did not take effect
Closed this issue · 4 comments
在wordpress5.3中按照wiki提供的nginx规则完成全部操作。站点首页被缓存,且页脚有cachify标记。文章页面没有换成,没有cachify标记。浏览器开发者模式也是这样,首页正常,内容页无法缓存。请给我一些建议。
Sorry, but - as far as I know - none of the team members is Chinese and I'm not sure if I got the issue right by Google translation. Please try to provide additional information in English.
What I understood:
You have set up Cachify on WP 5.3 with an nginx webserver. Homepage is cached correctly, but article pages not.
Do you use HDD cache or memcached with nginx?
Do you use a permalink structure or basic URLs with parameters?
Either way, are your article pages available in caching backend (i.e. file exists in cache directory for HDD backend) or are they not even generated?
I translated your reply in the opposite direction.
I use memcached for storage.
My link format is https: //domain/number.html.
For example http://www.github.com/123.html.
Visible in the homepage source code: "<!-Cachify | http://cachify.de
Memcached @ 05.12.2019 14:34:24-> ".
This code does not exist in the content page.
Here is my nginx vhost configuration:
listen 80;
listen 443 ssl http2;
ssl_certificate /usr/local/nginx/conf/ssl/github.com.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/github.com.key;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name www.github.com github.com;
access_log /data/wwwlogs/www.github.com_nginx.log combined;
index index.html index.htm index.php;
root /data/wwwroot/www.github.com;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
if ($host != www.github.com) { return 301 $scheme://www.github.com$request_uri; }
#加载定义配置开始
#启用Cachify开始
charset utf-8;
#启用Cachify结束
location / {
#try_files $uri $uri/ /index.php?$args;
#启用Cachify开始
error_page 404 405 = @nocache;
if ( $query_string ) {
return 405;
}
if ( $request_method = POST ) {
return 405;
}
#移动端不缓存
if ( $http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT-)|(SonyEricsson)|(NEC-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC-)|(SED-)|(EMOL-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)" )
{
return 405;
}
#移动端不缓存
if ( $request_uri ~ "/wp-" ) {
return 405;
}
if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
return 405;
}
default_type text/html;
add_header X-Powered-By Cachify;
set $memcached_key $host$uri;
memcached_pass 127.0.0.1:11211;
#启用Cachify结束
}
#启用Cachify开始
location @nocache {
try_files $uri $uri/ /index.php?$args;
}
#启用Cachify结束
#以下是原来的伪静态配置
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ~* ^/wp-content/uploads/.*\.php$ {
deny all;
}
#加载自定义配置结束
#error_page 404 /404.html;
#error_page 502 /502.html;
location ~ [^/]\.php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)?$ {
expires 7d;
access_log off;
}
location ~ /(\.user\.ini|\.ht|\.git|\.svn|\.project|LICENSE|README\.md) {
deny all;
}
}
Sorry, but - as far as I know - none of the team members is Chinese and I'm not sure if I got the issue right by Google translation. Please try to provide additional information in English.
What I understood:
You have set up Cachify on WP 5.3 with an nginx webserver. Homepage is cached correctly, but article pages not.Do you use HDD cache or memcached with nginx?
Do you use a permalink structure or basic URLs with parameters?
Either way, are your article pages available in caching backend (i.e. file exists in cache directory for HDD backend) or are they not even generated?
By reading the wiki, I found a similar problem.I don't know how to solve this problem.I use memcached to store cached data.
The HDD caching in Cachify can only be selected and used with activated WordPress permalinks. A slash at the end of the permalink is also needed. For permalinks without slash at the end, the use of a special .htaccess snippets is required. The snippet code replaces the provided .htaccess entry above.
thanks very much. I have finished caching through URL end matching.