商業源碼熱門下載www.html.org.cn
網頁緩存的作用是什么?應該很重要。但是我們在開發網絡應用的時候,網頁緩存總是給我們一種莫名的煩惱。于是幾乎每一個開發者都試圖解決過這個問題。當然,我也不是今天才著手解決這個問題。但是今天一時心血來潮,寫一篇,記錄一下用到的方法。
1.禁止客戶端緩存要在<head>中加入類似如下內容(我當然還沒有這么用過):
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="wed, 26 feb 1997 08:21:57 gmt">
2.在服務器的動態網頁中禁止緩存,要加入類似如下腳本
(1)asp(好久不用了):
<%
response.expires = -1
response.expiresabsolute = now() - 1
response.cachecontrol = "no-cache"
%>
(2)jsp(我現在經常用的):
response.setheader("pragma","no-cache");
response.setheader("cache-control","no-cache");
response.setdateheader("expires", 0);
新聞熱點
疑難解答