一般 web server 或 proxy 要 cache 網頁, 通常是用 url 來處理, 若是該 url 出現過, 就直接拿 cache output 給 client, 導致上述的狀況, 解決之道就是將 url 後, 加一些無意義的參數 (query string), 並且是隨機產生, 如此一來, web server 就得真的再去讀一次檔案, 就不容易 cache 網頁內容了.
在一般的 html 檔內, 可以透過以下語法進行
代碼: 選擇全部
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
in javascript (reload):
<a href=# onclick="window.location.href=window.location.href.substr(0, window.location.href.lastIndexOf('?'))+'?dd='+Math.random();return false;">reload</a>