慎用html5 application cache


在我們的3G版網站的項目中使用了html5 application cache,將大部分圖片資源、js、css等靜態資源放在manifest文件中。

沒想到上線第一天就遇到了嚴重問題:application cache會默認緩存當前頁面!!!就算我們有如下設置:

NETWORK:*

也就是說,對於所有的動態頁面,application cache會緩存起來,用戶怎么刷新都是老的!

而且手機瀏覽器還很難清除掉,也不支持js清除!

花了一個上午,嘗試了很多辦法,查了很多資料,都沒能清除掉客戶端的緩存。一上午被用戶投訴慘了。

最后還是萬能的stackoverflow救了我:

  1. Do not use appcache unless it is REALLY 100% EXACTLY WHAT YOU WANT TO DO
  2. 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.
  3. 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.
  4. Don't turn it on again until it's 100% CORRECT
  5. Dealing with appcache is miserable, often.

解決辦法很簡單,在服務器端刪除掉manifest文件,並且慎用application cache

 

當然,也有辦法是用application cache,同時能繞過自動緩存當前頁面的問題。那就是用iframe:http://sofish.de/1449

 

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

承接微信公眾平台消息接口開發、PHP、.NET、javascript、html5程序開發;新浪微博應用、騰訊微博應用等各大開放平台應用開發業務

聯系QQ:1433273389 

關注媽媽助手(賬號mmhelper)方法:

1. 依次進入以下路徑:朋友們—>添加朋友—>搜號碼,輸入mmhelper,不區分大小寫,點擊查找,然后點擊關注。

2. 掃描二維碼:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM