php操作是只能做到不缓存// Date in the past,现在小编就来说说关于浏览器如何强制清除缓存?下面内容希望能帮助到你,我们来一起看看吧!
浏览器如何强制清除缓存
php操作是只能做到不缓存
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("cache-control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
关于IE取消缓存的代码
header("cache-control:no-cache,must-revalidate");
header("pragma:no-cache");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
这里的作用是防止IE缓存一些不需要缓存的数据。
添加随机码,防止IE缓存,目的是使每次访问的数据都不一样
<img src="/services/main/online_status.php?cyid=<?=$int_cyid?>&rand=<?=$time?>" height="11" width="11" />
也可以在js中添加时间戳来防止缓存,当然在src这个路径上加上时间戳也是能够防止缓存的:如:
src="../../music/cyworld_music_player.swf?time=' new Date() '"
href="http://cyworld_music_player.swf?time=' new Date() '" 来防止缓存问题的出现。
,