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

將照片加入簽名檔

將照片加入簽名檔

我始終相信,科技來自於人性... 而我的人性則是來自於墮性.... 開發 innstory.com ...

吉他手

吉他手

回屏東,跟外甥女借了吉他回台北,想說,兒子二胡學習的還不錯,會不會是有部份也是遺傳了我未開發音樂基因...

動態留言功能調整

動態留言功能調整

guestmap55 最近改進了朋友動態的發文方式.... 一開始在功能方面加上了googlemap...

Recommended reading

Other stories happened at this address

Is raining,funny duck family.

Is raining,fun...

Is raining,funny duck family.

千呼萬喚屎出來

千呼萬喚屎出來

首先,請原諒我使用較生活化的詞彙。 說說照顧U這近年的時間的感想,我覺得最大的痛苦莫過於擔心他不進、...

舒服了~

舒服了~

舒服了~

就是要這樣挨著~

就是要這樣挨著~

s 忘了從甚麼時候開始~U睡覺喜歡挨在我身邊。 每當我坐在床上,他會開心的從遠處爬來。 然後一個翻身...

剪髮初體驗~

剪髮初體驗~

第天,剪髮初體驗~由阿婆親自操刀。 這傢伙很淡定啊,看來他根本不知道即將要發生什麼事。 果然,阿婆還...

10個月的5U,吃個飯像大爺啊~( ̄∇ ̄)

10個月的5U,吃個飯像大爺...

image U十個月了。 充滿好奇心的年紀,雖然會認人了,但試驗了幾次之後似乎不怎麼怕生。 不挑食,...

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