Loading...

清除網頁暫存(no cache)

Temperature: 0 °C

ChungChung
author_tools


清除網頁暫存(no cache)
在製作專案時,有沒有試過JS 或 CSS 明明就已經更新了~

但頁面卻像鬼打牆一樣,不管怎樣重新整理就是無法取得新更新的資料尤其是Chrome。

以下有幾方式~

在PHP

// 清空伺服器緩存
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

在HTML
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">

其實以上方式都試過,但針對CSS及JS檔案Chrome效果真的有限~

總不能老是把暫存檔清掉或使用無痕視窗吧⊙_⊙

於是乎用了另一種方式來強制更新的CSS檔案。
<link rel="stylesheet" href="assets/css/style.css?20171106" />

就是在CSS後面加上?以及日期或者亂數,這樣瀏覽器就可以判斷為不同版本,以便取得最新的CSS或JS。

以上,脫離鬼打牆後,痛哭流涕紀錄~

台北市內湖區江南街71巷75弄 Go

https://innstory.com/story-清除網頁暫存no_cache-1429
寫程式筆記

Prev
 搶東西吃搶到現在是誰的舌頭先舔到誰就贏的狀態╮ ̄▽ ̄╭

Next
嘰嘰喳喳 

Nearby Attractions

台北市內湖區江南街71巷75弄-Nearby Attractions

  • 北投溫泉浴場 Go
  • 骨科醫院及住宅 Go
  • 內湖郭氏古宅 Go
  • 臺北公會堂 Go
  • 慈雲寺 Go
  • 臨濟護國禪寺 Go

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

小小消防員初體驗

小小消防員初體驗

年月日,5U幼兒園參加消防夏令營。

用distinct在MySQL中查詢多條不重複記錄值

用distinct在MySQ...

select *, count(distinct name) from table group by...

IE10 在 fckeditor無正常顯示及無法輸入任何字元

IE10 在 fckedit...

於fckorcodeie.js 檔案中, 在B.open(‘GET’, A, false); 及 B...

Recommended reading

Other stories happened at this address

9個月了​​​​​​​,有時希望他快點長大​​​​​​​,有時又希望時間慢一點​​​​​​​。

9個月了​​​​​​​,有時...

s 個月了,看看這傢伙學會了些甚麼? 笑點一樣很低,呵呵呵的笑聲總是能讓我暫時放下手邊的一切只是看著...

新舊交替,使用phpmyadm出現1064 error in CREATE TABLE … TYPEMYISAM錯誤

新舊交替,使用phpmyad...

sql 系統移機的過程中,最重要的環節....我想...莫過於是系統的環境了....。 這次在協助移...

我們家提前過月亮節囉~

我們家提前過月亮節囉~

我們家提前過月亮節囉~

聖誕節快樂,恩~我想從現在開始一直到農曆新年結束...應該都保持休假心態吧XD

聖誕節快樂,恩~我想從現在開...

聖誕節快樂,恩~我想從現在開始一直到農曆新年結束...應該都保持休假心態吧XD

曬衣架上的幸福...

曬衣架上的幸福...

月日,今天週了.....早上產檢一切順利。 活動力強已經是小傢伙的本性了,這幾天當然也不例外,醫生大...

最遙遠的距離

最遙遠的距離

s 通訊軟體看似拉近了彼此的距離。 殊不知,心的距離才是最遙遠的。 已讀未回。

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format