【发布时间】:2019-11-21 04:19:50
【问题描述】:
我想要禁用客户端浏览器缓存的 WordPress 站点中的特定页面。
我找到了一个插件 (https://wordpress.org/plugins/prevent-browser-caching/),但出于维护/安全原因,我们希望避免添加不必要的插件。
我还找到了一种使用 HTTP 标头 (How do we control web page caching, across all browsers?) 执行此操作的方法,但是当 WordPress 呈现页面时,操作标头为时已晚。
我正在做这个自定义 PHP,但它陷入了一个无限循环......想法?
if ($department == "xxxxxxxxxx" && time() - $_GET['nocache'] > 1) {
echo time() - $_GET['nocache'];
?>
<html>
<body>
<script>
var curr_page = window.location.href,
next_page = "";
next_page = curr_page + "?nocache=" + <?= time()?>;
window.location = next_page;
</script>
</body>
</html>
<?php
die();
}
【问题讨论】: