tft每日頭條

 > 生活

 > 浏覽器如何強制清除緩存

浏覽器如何強制清除緩存

生活 更新时间:2024-08-01 11:09:43

浏覽器如何強制清除緩存?php操作是隻能做到不緩存// Date in the past,現在小編就來說說關于浏覽器如何強制清除緩存?下面内容希望能幫助到你,我們來一起看看吧!

浏覽器如何強制清除緩存(如何禁止浏覽器緩存)1

浏覽器如何強制清除緩存

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() '" 來防止緩存問題的出現。

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved