WordPress使用Cachify加速waiting ttfb加载时间

wordpress速度优化总是一个老生常谈的课题。最近有一个项目基于wordpress,网站页面接近10万+,访问造成的大量数据库查询,服务器时常负载跑满自闭。。于是便有了此篇文章。

Cachify插件下载:

https://cn.wordpress.org/plugins/cachify/

或者在wordpress后台搜索: Cachify

配置方法:

配置方法非常简单,这里缓存方式推荐使用Mencached。(使用的前提需求服务器安装Mencached)

%title插图%num

伪静态规则:

插件内选项配置好之后,需要在 Nginx 站点伪静态中 添加下边的规则。

然后重启Nginx 服务,即可生效。

location ~ / {
error_page 404 405 = @nocache;

if ( $query_string ) {
return 405;
}
if ( $request_method = POST ) {
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 localhost:11211;
}

location @nocache {
try_files $uri $uri/ /index.php?$args;
}

查看方法:

%title插图%num

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容