为什么我的页面不会停止缓存?

发布于 2024-12-16 18:29:20 字数 1106 浏览 4 评论 0原文

我正在使用这个标题(见下文)。 那么为什么我的页面在 IE 上一直缓存???

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <META NAME="MSSmartTagsPreventParsing" CONTENT="True">
 <META HTTP-EQUIV="Expires" CONTENT="0">
 <META HTTP-EQUIV="Pragma" CONTENT="No-Cache">
 <META HTTP-EQUIV="Cache-Control" CONTENT="No-Cache,Must-Revalidate,No-Store">
 <META NAME="Robots" CONTENT="NoIndex,NoFollow">
 <META ondragstart="return false" onselectstart="return false" http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

问题已解决!!! 使用 .php 代替 .html 或 .htm,并使用如下所示的 php 标头:

<?php
 header("Cache-Control: no-cache, must-revalidate");
 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
 header("Cache-Control: no-cache, no-store, must-revalidate");
 header("Pragma: no-cache");
?>

i am using this header (see below).
So why do my pages keep caching on IE???

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <META NAME="MSSmartTagsPreventParsing" CONTENT="True">
 <META HTTP-EQUIV="Expires" CONTENT="0">
 <META HTTP-EQUIV="Pragma" CONTENT="No-Cache">
 <META HTTP-EQUIV="Cache-Control" CONTENT="No-Cache,Must-Revalidate,No-Store">
 <META NAME="Robots" CONTENT="NoIndex,NoFollow">
 <META ondragstart="return false" onselectstart="return false" http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

PROBLEM SOLVED!!! Instead of .html or .htm use .php and use a php header like this one:

<?php
 header("Cache-Control: no-cache, must-revalidate");
 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
 header("Cache-Control: no-cache, no-store, must-revalidate");
 header("Pragma: no-cache");
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走干脆点 2024-12-23 18:29:20

除了其他建议之外,尝试向页面请求添加动态值,这将有更好的机会不缓存。

(即 /foo.html?a=9585874034854 (或纪元或其他动态的东西)。

此外,您的标头需要:
Cache-Control: no-cache, no-store

告诉系统不缓存它,甚至不将它存储在缓存中。

Aside from the other suggestions try adding a dynamic value to the page request, that'll have a better chance of not caching.

(i.e. /foo.html?a=9585874034854 (or epoch or something else just as dynamic).

Also, your header needs:
Cache-Control: no-cache, no-store

That tells the system don't cache it or even store it in cache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文