kevin0490 发表于 2017-4-2 08:48:12

PHP不加载缓存的操作

  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()+'"   来防止缓存问题的出现。

页: [1]
查看完整版本: PHP不加载缓存的操作