大佬教程收集整理的这篇文章主要介绍了如何正确无效的HTML5缓存清单的在线/离线网络应用程序?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
不幸的是,它的工作有点太好了。
加载缓存清单后,Firefox 3.5缓存缓存清单中显式引用的所有资源。但是,如果服务器上的文件被更新,并且用户尝试在线时强制刷新页面(包括缓存清单本身),Firefox将绝对拒绝提取任何内容。应用程序在缓存的最后一个点处保持完全冻结。问题:
>我想让Firefox有效地只依靠缓存的资源,当网络连接失败。我试过使用falLBACK块,但没有效果。这是可能吗?
>如果#1不可能,用户是否可能强制刷新页面并绕过此缓存(ctrl-F5不会这样做,也不清除浏览器的缓存,没有清除其私有数据)?或者,缓存清单机制是否支持过期标头,并且是否相对于此记录在任何地方的行为?
为了揭示这是问题,我borrowed some code from Mozilla并将其删除到一个新的(非缓存)HTML文件在我的应用程序。记录的最终消息表明,我的缓存清单可能有问题,并且确定有足够的(一个缺少的文件)。
// Convenience array of status values var cacheStatusValues = []; cacheStatusValues[0] = 'uncached'; cacheStatusValues[1] = 'idle'; cacheStatusValues[2] = 'checking'; cacheStatusValues[3] = 'downloading'; cacheStatusValues[4] = 'updateready'; cacheStatusValues[5] = 'obsolete'; // Listeners for all possible events var cache = window.applicationCache; cache.addEventListener('cached',logEvent,falsE); cache.addEventListener('checking',falsE); cache.addEventListener('downloading',falsE); cache.addEventListener('error',falsE); cache.addEventListener('noupdate',falsE); cache.addEventListener('obsolete',falsE); cache.addEventListener('progress',falsE); cache.addEventListener('updateready',falsE); // Log every event to the console function logEvent(E) { var online,status,type,message; online = (isOnline()) ? 'yes' : 'no'; status = cacheStatusValues[cache.status]; type = e.type; message = 'online: ' + online; message+= ',event: ' + type; message+= ',status: ' + status; if (type == 'error' && navigator.onLinE) { message+= ' There was an unkNown error,check your Cache Manifest.'; } log('
'+messagE); } function log(s) { alert(s); } function isOnline() { return navigator.onLine; } if (!$('html').attr('manifest')) { log('No Cache Manifest listed on the tag.') } // Swap in newly download files when update is ready cache.addEventListener('updateready',function(E){ // Don't perform "swap" if this is the first cache if (cacheStatusValues[cache.status] != 'idle') { cache.swapCache(); log('Swapped/updated the Cache Manifest.'); } },falsE); // these two functions check for updates to the manifest file function checkForupdates(){ cache.@R_675_4457@; } function autocheckForupdates(){ seTinterval(function(){Cache.@R_675_4457@},10000); } return { isOnline: isOnline,checkForupdates: checkForupdates,autocheckForupdates: autocheckForupdates }
这当然有帮助,但我一定要从Mozilla的功能,打印出格式不正确的缓存清单至少到错误控制台。它不应要求自定义代码附加到这些事件,以将问题诊断为与重命名的文件不重要。
以上是大佬教程为你收集整理的如何正确无效的HTML5缓存清单的在线/离线网络应用程序?全部内容,希望文章能够帮你解决如何正确无效的HTML5缓存清单的在线/离线网络应用程序?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。