HTML5的离线存储applicationCache

html5离线应用接口规范

网址:https://html.spec.whatwg.org/#applicationcache

interface ApplicationCache : EventTarget {

  // update status
  const unsigned short UNCACHED = 0;
  const unsigned short IDLE = 1;
  const unsigned short CHECKING = 2;
  const unsigned short DOWNLOADING = 3;
  const unsigned short UPDATEREADY = 4;
  const unsigned short OBSOLETE = 5;
  readonly attribute unsigned short status;

  // updates
  void update();
  void abort();
  void swapCache();

  // events
  attribute EventHandler onchecking;
  attribute EventHandler onerror;
  attribute EventHandler onnoupdate;
  attribute EventHandler ondownloading;
  attribute EventHandler onprogress;
  attribute EventHandler onupdateready;
  attribute EventHandler oncached;
  attribute EventHandler onobsolete;
};

1.离线资源的缓存

离线应用将使用manifest类型的文件作为需要配置缓存文件的配置文件

2.ApplicationCache

ApplicationCache对象记录着web应用程序的缓存状态,开发者可以通过该缓存状态手动更新资源文件的缓存。

3.在线状态监测

html5标准提供online方法用于检测当前网络是否在线。

window.navigator.online

监听事件

applicationCache.addEventListener('updateready',function(){
    alert("离线文件下载完毕");
});

 包含的事件名为:

checking

noupdate

downloading

progress

cached

updateready

obsolete

error


HTML5的离线存储applicationCache
 

相关推荐