html5 application cache遇到的嚴(yán)重問題
發(fā)布時間:2012-12-26 17:26:05 作者:佚名
我要評論

在我們的3G版網(wǎng)站的項目中使用了html5 application cache,將大部分圖片資源、js、css等靜態(tài)資源放在manifest文件中,需要了解的朋友可以參考下
在我們的3G版網(wǎng)站的項目中使用了html5 application cache,將大部分圖片資源、js、css等靜態(tài)資源放在manifest文件中。
沒想到上線第一天就遇到了嚴(yán)重問題:application cache會默認(rèn)緩存當(dāng)前頁面?。?!就算我們有如下設(shè)置:
NETWORK:*
也就是說,對于所有的動態(tài)頁面,application cache會緩存起來,用戶怎么刷新都是老的!
而且手機瀏覽器還很難清除掉,也不支持js清除!
花了一個上午,嘗試了很多辦法,查了很多資料,都沒能清除掉客戶端的緩存。一上午被用戶投訴慘了。
最后還是萬能的stackoverflow救了我:
Do not use appcache unless it is REALLY 100% EXACTLY WHAT YOU WANT TO DO
Even if it IS 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 links to) for a LONG time.
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.
解決辦法很簡單,在服務(wù)器端刪除掉manifest文件,并且慎用application cache
當(dāng)然,也有辦法是用application cache,同時能繞過自動緩存當(dāng)前頁面的問題。那就是用iframe
沒想到上線第一天就遇到了嚴(yán)重問題:application cache會默認(rèn)緩存當(dāng)前頁面?。?!就算我們有如下設(shè)置:
復(fù)制代碼
代碼如下:NETWORK:*
也就是說,對于所有的動態(tài)頁面,application cache會緩存起來,用戶怎么刷新都是老的!
而且手機瀏覽器還很難清除掉,也不支持js清除!
花了一個上午,嘗試了很多辦法,查了很多資料,都沒能清除掉客戶端的緩存。一上午被用戶投訴慘了。
最后還是萬能的stackoverflow救了我:
Do not use appcache unless it is REALLY 100% EXACTLY WHAT YOU WANT TO DO
Even if it IS 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 links to) for a LONG time.
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.
解決辦法很簡單,在服務(wù)器端刪除掉manifest文件,并且慎用application cache
當(dāng)然,也有辦法是用application cache,同時能繞過自動緩存當(dāng)前頁面的問題。那就是用iframe
相關(guān)文章
Application Cache未緩存文件無法訪問無法加載問題
使用Application Cache緩存了頁面及靜態(tài)資源,在加載未緩存的資源時無法加載,并且有報錯,下面為大家介紹個解決方法2014-05-31HTML5使用ApplicationCache接口實現(xiàn)離線緩存技術(shù)解決離線難題
離線訪問對基于網(wǎng)絡(luò)的應(yīng)用而言越來越重要,雖然所有瀏覽器都有緩存機制,但它們并不可靠,HTML5 使用 ApplicationCache 接口解決了由離線帶來的部分難題,需要的朋友可以參考2012-12-13HTML5實現(xiàn)應(yīng)用程序緩存(Application Cache)
這篇文章主要介紹了HTML5實現(xiàn)應(yīng)用程序緩存(Application Cache),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編2020-06-16