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緩存,目的是使每次訪問的數據都不一樣
也可以在js中添加時間戳來防止緩存,當然在src這個路徑上加上時間戳也是能夠防止緩存的:如:
class="lazy" src="//p2.ttnews.xyz/loading.gif" data-original="../../music/cyworld_music_player.swf?time='+ new Date()+'"
href="http://cyworld_music_player.swf?time='+ new Date()+'" 來防止緩存問題的出現。
閱讀更多 老公城獅 的文章