php - 如何在 /wp-admin/* 中禁用缓存
问题描述
原因,为什么我需要禁用缓存:
当我创建帖子或页面时。它缓存它的。如果我创建第二个帖子或页面,那么它会更新旧帖子或页面。当我为每个页面禁用缓存时,此错误已修复。虽然我需要 SEO 缓存。
所以,我只需要在管理页面中禁用缓存。
.htaccess
<ifModule mod_headers.c>
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|woff2)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\.(css|js)$">
Header set Cache-Control "max-age=86400, public"
</filesMatch>
<filesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</filesMatch>
<filesMatch "\.(html|htm|php)$">
Header set Cache-Control "max-age=1800, private, must-revalidate"
</filesMatch>
<FilesMatch "\.(js|css|jpg|png|jpeg|gif|xml|json|txt|pdf|mov|avi|otf|woff|ico|swf)$">
RequestHeader unset Cookie
Header unset Cookie
Header unset Set-Cookie
</FilesMatch>
# Guarantee HTTPS for 1 Year including Sub Domains
Header always set Strict-Transport-Security "max-age=31536000;"
</ifModule>
函数.php
if (is_admin()) {
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
}
我在 function.php 中的代码不起作用。
解决方案
从 .htacess 中删除此行
Header set Cache-Control “max-age=86400, public”
推荐阅读
- firebase - FieldValue.increment 导致 Flutter 崩溃
- swiftui - Why does a SwiftUI animation behave and align differently on iOS and macOS?
- javascript - 如何调试 Stanza.js 身份验证?
- reactjs - Nginx路由和刷新导致404
- google-apps-script - 填写表格后为每个受访者生成一个代码
- xml - 使用 PowerShell 从注释掉的 XML 值创建变量
- visual-studio-app-center - appcenter是否支持连接苹果商店?
- algorithm - 有效地更新 AVL 树中的多个节点?
- discord.js - 命令冷却 discord.js
- python - Pyglet - 一次移动多个形状