HTML5离线缓存Manifest是什么

2020-04-21 22:50:55易采站长站整理

    
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);   

如果manifest文件或者该文件中指定的某个资源下载失败,那么整个更新都会失败。在这种情况下,浏览器会继续试用老的application cache。

注意事项:

1. 站点离线存储的容量限制是5M
2. 如果manifest文件,或者内部列举的某一个文件不能正常下载,整个更新过程将视为失败,浏览器继续全部使用老的缓存
3. 引用manifest的html必须与manifest文件同源,在同一个域下
4. 在manifest中使用的相对路径,相对参照物为manifest文件
5. CACHE MANIFEST字符串应在第一行,且必不可少
6. 系统会自动缓存引用清单文件的 HTML 文件
7. manifest文件中CACHE则与NETWORK,FALLBACK的位置顺序没有关系,如果是隐式声明需要在最前面
8. FALLBACK中的资源必须和manifest文件同源
9. 当一个资源被缓存后,该浏览器直接请求这个绝对路径也会访问缓存中的资源。