我已经在“缓存和速度设置”下将“整页缓存”打开为“在所有情况下”,并通过清除缓存并在单独的浏览器中加载我的主页来测试它。但是无论我刷新多少次浏览器,加载时间似乎都保持不变,这让我相信 CMS 仍然会去数据库检索页面,而不是从缓存中检索。
我设法将代码跟踪到 /concrete/src/Cache/Page/PageCache.php 中的这一位
/**
* Note: can't use the User object directly because it might query the database.
* Also can't use the Session wrapper because it starts session which triggers
* before package autoloaders and so certain access entities stored in session
* will break.
*/
public function shouldCheckCache(Request $req) {
$session = \Config::get('concrete.session.name');
$r = \Cookie::get($session);
if ($r) {
return false;
}
return true;
}
如果我强制此函数始终返回 true,我会发现浏览器的后续重新加载会看到更短的加载时间,我相信这表明该页面是从缓存中检索的。
该函数似乎检查是否已设置“CONCRETE5”cookie。如果是这样,那么缓存将被忽略。我真的不明白这一切意味着什么,所以希望有人能帮助阐明我是否做错了什么,或者我应该做什么。
感谢您的任何帮助!