From 17f3a3c551dfa7d986fc7865b07368cf4b8f2936 Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Thu, 15 Jan 2026 22:49:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=BC=BA=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD=20-=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0HTTP=E7=A6=81=E6=AD=A2=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=A4=B4=E5=92=8C=E5=89=8D=E7=AB=AF=E7=BC=93=E5=AD=98=E6=B8=85?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 17 ++++++++++++++++- header.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index b93e9cb..b007193 100644 --- a/functions.php +++ b/functions.php @@ -61,11 +61,26 @@ function argon_is_force_refresh_enabled() { */ function argon_get_assets_version() { if (argon_is_force_refresh_enabled()) { - return $GLOBALS['theme_version'] . '.' . time(); + // 使用启用时间作为版本号,确保同一小时内版本一致但与之前不同 + $enabled_time = get_option('argon_force_refresh_enabled_time', 0); + return $GLOBALS['theme_version'] . '.r' . $enabled_time; } return $GLOBALS['theme_version']; } +/** + * 强制刷新时发送禁止缓存的 HTTP 头 + */ +function argon_force_refresh_headers() { + if (!is_admin() && argon_is_force_refresh_enabled()) { + header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); + header('Pragma: no-cache'); + header('Expires: Thu, 01 Jan 1970 00:00:00 GMT'); + header('X-Argon-Force-Refresh: enabled'); + } +} +add_action('send_headers', 'argon_force_refresh_headers'); + /** * 启用强制刷新缓存 */ diff --git a/header.php b/header.php index 46f488e..f1355b2 100644 --- a/header.php +++ b/header.php @@ -292,6 +292,51 @@ + + + + +