为什么我的页面不会停止缓存?
我正在使用这个标题(见下文)。 那么为什么我的页面在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了其他建议之外,尝试向页面请求添加动态值,这将有更好的机会不缓存。
(即 /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.