本文實例匯總了各類常見語言清除網頁緩存方法。分享給大家供大家參考。具體實現方法如下:
一般來說,清除緩存我們只需要設置頁面為no-cache就可以了,當然像asp,php這種只需要設置Expires操作即可,具體如下。
HTML網頁:
復制代碼 代碼如下:
<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">
或者復制代碼 代碼如下:
<META HTTP-EQUIV="expires" CONTENT="0">
ASP網頁:
復制代碼 代碼如下:
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
PHP網頁:
復制代碼 代碼如下:
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
JSP網頁:
復制代碼 代碼如下:
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 1);
希望本文所述對大家的web程序設計有所幫助。