你的位置:首页 > 软件开发 > 网页设计 > HTML5离线缓存Manifest

HTML5离线缓存Manifest

发布时间:2015-10-12 15:00:06
web app不比PC,有性能和流量方面的考虑,离线应用越来越重要,虽然浏览器有缓存机制,但是时常不靠谱,更何况普通情况下html文件是没法缓存的,断网之后一切over。什么是manifest?简单来说manifest能让你的应用在无网的情况下也能访问。它有三大优势:1、离线浏览 ...

web app不比PC,有性能和流量方面的考虑,离线应用越来越重要,虽然浏览器有缓存机制,但是时常不靠谱,更何况普通情况下html文件是没法缓存的,断网之后一切over。

什么是manifest?

简单来说manifest能让你的应用在无网的情况下也能访问。

它有三大优势:

1、离线浏览,无网情况下也能正常访问;

2、更快的加载速度,缓存在本地访问速度自然更快;

3、减轻服务请求压力,文件缓存后不需要再次请求,只需要请求需要更新的文件。

如何使用?

<!DOCTYPE HTML><html manifest="demo.appcache">...</html>
更新机制// Fired after the first cache of the manifest.appCache.addEventListener(‘cached’, handleCacheEvent, false); // Checking for an update. Always the first event fired in the sequence. appCache.addEventListener(‘checking’, handleCacheEvent, false); // An update was found. The browser is fetching resources. appCache.addEventListener(‘downloading’, handleCacheEvent, false); // The manifest returns 404 or 410, the download failed, // or the manifest changed while the download was in progress. appCache.addEventListener(‘error’, handleCacheError, false); // Fired after the first download of the manifest. appCache.addEventListener(‘noupdate’, handleCacheEvent, false); // Fired if the manifest file returns a 404 or 410. // This results in the application cache being deleted. appCache.addEventListener(‘obsolete’, handleCacheEvent, false); // Fired for each resource listed in the manifest as it is being fetched. appCache.addEventListener(‘progress’, handleCacheEvent, false); // Fired when the manifest resources have been newly redownloaded. appCache.addEventListener(‘updateready’, handleCacheEvent, false);

原标题:HTML5离线缓存Manifest

关键词:HTML

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。