html5 application cache遇到的嚴(yán)重問(wèn)題

字號(hào):


    在我們的3G版網(wǎng)站的項(xiàng)目中使用了html5 application cache,將大部分圖片資源、js、css等靜態(tài)資源放在manifest文件中。
    沒(méi)想到上線第一天就遇到了嚴(yán)重問(wèn)題:application cache會(huì)默認(rèn)緩存當(dāng)前頁(yè)面?。。【退阄覀冇腥缦略O(shè)置:
    代碼如下:
    NETWORK:*
    也就是說(shuō),對(duì)于所有的動(dòng)態(tài)頁(yè)面,application cache會(huì)緩存起來(lái),用戶怎么刷新都是老的!
    而且手機(jī)瀏覽器還很難清除掉,也不支持js清除!
    花了一個(gè)上午,嘗試了很多辦法,查了很多資料,都沒(méi)能清除掉客戶端的緩存。一上午被用戶投訴慘了。
    最后還是萬(wàn)能的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.
    解決辦法很簡(jiǎn)單,在服務(wù)器端刪除掉manifest文件,并且慎用application cache
    當(dāng)然,也有辦法是用application cache,同時(shí)能繞過(guò)自動(dòng)緩存當(dāng)前頁(yè)面的問(wèn)題。那就是用iframe