HTML5 缓存 list : Fallback section & Network *

标签 html cache-manifest

来自 Dive into HTML5: Cache Manifest: Fallback section

CACHE MANIFEST
FALLBACK:
/ /offline.html
NETWORK:
*

鉴于此代码块的确切作用,我无法从 URL 中理解。回退部分是否意味着当找不到任何东西时,显示 offline.html 页面

那么network:*所有资源都会被缓存?它也说

It uses common CSS, JavaScript, and images on each page. Each of these resources would need to be listed explicitly in the CACHE

这似乎与 network: * 冲突,它似乎说缓存所有内容?

最佳答案

缓存 list 中有三种类型的标题,CACHE、NETWORK 和 FALLBACK。不在标题下的任何内容都隐式设置在 CACHE 下。每个部分的解释:

CACHE:此标题下的文件将被缓存。

网络:此标题下的文件需要互联网连接,因此不会被缓存。

回退:与此标题下的模式匹配(例如匹配所有文件的模式“/”)且未被缓存的文件将显示一个回退文件。

关于 Dive into HTML 5 中的代码块,在其正下方有对“NETWORK: *”部分的解释:

It means that, while you’re browsing this hypothetical offline-enabled Wikipedia online, your browser will fetch images and videos and other embedded resources normally, even if they are on a different domain. (This is common in large websites, even if they aren’t part of an offline web application. HTML pages are generated and served locally, while images and videos are served from a CDN on another domain.) Without this wildcard flag, our hypothetical offline-enabled Wikipedia would behave strangely when you were online — specifically, it wouldn’t load any externally-hosted images or videos!

以下引用:

It uses common CSS, JavaScript, and images on each page. Each of these resources would need to be listed explicitly in the CACHE

表示您必须在缓存标题下的 list 中包含所有必要的 CSS、Javascript 和图像文件。它不会与“NETWORK: *”冲突,因为 NETWORK 标题确实NOT 表示“缓存所有内容”。它实际上意味着相反:NETWORK 标题下的所有内容都需要互联网连接,不应缓存。

关于HTML5 缓存 list : Fallback section & Network *,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3281827/

相关文章:

javascript - 如何找到文本容器中最后一个可见单词的位置?

javascript - $ ('html' ).click()...除一个元素外的任何地方

html - 如何在 HTML5 应用程序缓存中缓存多个包含页面特定图像和共享资源的 HTML 页面?

javascript - 离线缓存 - html5

html - HTML5 离线应用程序中的文件上传

javascript - WebApp 基本问题

javascript - 如何在我的案例中创建一系列动画?

jquery - 跨浏览器支持需要哪些音频格式?

javascript - HTML5 - ApplicationCache 不更新(仅)某些文件

javascript - HTML5 缓存行为不当