html5 application cache遇到的严重问题
发布时间:2012-12-26 17:26:05 作者:佚名 我要评论
在我们的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 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.
解决办法很简单,在服务器端删除掉manifest文件,并且慎用application cache
当然,也有办法是用application cache,同时能绕过自动缓存当前页面的问题。那就是用iframe
没想到上线第一天就遇到了严重问题:application cache会默认缓存当前页面!!!就算我们有如下设置:
复制代码
代码如下:NETWORK:*
也就是说,对于所有的动态页面,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.
解决办法很简单,在服务器端删除掉manifest文件,并且慎用application cache
当然,也有办法是用application cache,同时能绕过自动缓存当前页面的问题。那就是用iframe
相关文章
Application Cache未缓存文件无法访问无法加载问题
使用Application Cache缓存了页面及静态资源,在加载未缓存的资源时无法加载,并且有报错,下面为大家介绍个解决方法2014-05-31HTML5使用ApplicationCache接口实现离线缓存技术解决离线难题
离线访问对基于网络的应用而言越来越重要,虽然所有浏览器都有缓存机制,但它们并不可靠,HTML5 使用 ApplicationCache 接口解决了由离线带来的部分难题,需要的朋友可以参考2012-12-13HTML5实现应用程序缓存(Application Cache)
这篇文章主要介绍了HTML5实现应用程序缓存(Application Cache),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编2020-06-16
最新评论