WordPress搭配阿里云CDN总体比较简单,但有几个地方需要注意。
1、控制台需要设置wp-admin目录不缓存,其他文件缓存时间按需要设置,像我连php都缓存1小时。

2、在你的主题functions.php中加入如下代码关闭no-cache响应头(非常重要)
function Cache_Control(){
if (!is_user_logged_in()) {
header_remove("Cache-Control");
}
if(is_home() && !is_user_logged_in()){
header('Cache-Control: s-maxage=3600');
}
}
add_action( 'wp', 'Cache_Control' );
max-age为缓存的时间,单位为秒,可以自行设置。
如果不加的话就会这样。

接下来就可以去测试一下,一片绿

文章评论