在我們的3G版網站的專案中使用了html5 application cache,將大部分圖片資源、js、css等靜態資源放在manifest檔案中,需要了解的朋友可以參考下
在我們的3G版網站的專案中使用了html5 application cache,將大部分圖片資源、js、css等靜態資源放在manifest檔案中。
沒想到上線第一天就遇到了嚴重問題:application cache會預設快取目前頁面! ! !就算我們有如下設定:
程式碼如下:
NETWORK:*
也就是說,對於所有的動態頁面,application cache會快取起來,使用者怎麼刷新都是老的!
而且手機瀏覽器還很難清除掉,也不支援js清除!
花了一個上午,嘗試了很多辦法,查了很多資料,都沒能清除掉客戶端的快取。一上午被用戶投訴慘了。
最後還是萬能的stackoverflow救了我:
Do not use appcache unless it is REALLY 100% EXACTLY WHAT YOU WANT TO 100% WANT 100% EXACTLY WHAT YOU WANT TO DO, *DO NOT* use appcache until you are 100% CERTAIN that you are not going to make a single change to that page (or any file that it going to make a single change to that page (or any file that it links totime) for LOingle >Delete the manifest file from the server -- if the browser can't find the manifest file, then it will clear its cache... ...this will also turn caching off for everyone.
Don't turn it on again until it's 100% CORRECT
Dealing with appcache is miserable, often.
解決辦法很簡單,在伺服器端刪除掉manifest文件,並且慎用application cache