HTML5缓存清单:后备部分&网络* [英] HTML5 Cache Manifest: Fallback section & Network *

查看:147
本文介绍了HTML5缓存清单:后备部分&网络*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自深入了解HTML5:缓存清单:后备部分

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

我不明白这个代码块究竟做了什么的URL。回退部分的意思是什么时候找不到任何东西,显示 offline.html 页面

i dont understand from the URL given what this block of code exactly does. does the fallback section mean when anything is not found, show the offline.html page

然后 network:* 所有资源都将被缓存?它也说

then network: * all resources will be cached? it says also


它在每个页面上使用常见的CSS,JavaScript和
图像。这些
资源中的每一个都需要在 CACHE


中明确列出

这似乎与网络冲突:* 它似乎说缓存一切?

推荐答案

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

There are three types of headings in a cache manifest, CACHE, NETWORK and FALLBACK. Anything that is not under a heading is implicitly set under CACHE. An explanation of each section:

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

CACHE: Files under this heading will be cached.

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

NETWORK: Files under this heading require an internet connection and so will be NOT be cached.

FALLBACK:此标题下的模式匹配的文件(例如模式/,匹配所有文件)并且尚未缓存,将显示一个后备文件。

FALLBACK: Files matched by patterns under this heading (Such as the pattern "/", which matches all files) and have not been cached, will have a fallback file shown instead.

关于从潜水到HTML 5的代码块,有一个解释NETWORK:*部分就在它下面:

With regards to the block of code from Dive into HTML 5, there is an explanation of the "NETWORK: *" part just under it:


这意味着,当您在线浏览
这个假设的离线启用的
维基百科时,您的浏览器将获得
获取图像和视频以及其他$ b通常是$ b嵌入资源,即使
它们位于不同的域中。 (这个
在大型网站中很常见,即使
它们不属于离线网络
应用程序.HTML页面生成
并在本地提供,而图像和
视频是通过CDN在
另一个域上提供的。)如果没有这个通配符
标志,我们假设的离线启用的
维基百科在你上线
时会表现得很奇怪 - 具体来说,它
不会加载任何外部托管的
图像或视频!

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!

以下引用:


它在每个页面上使用常见的CSS,JavaScript和
图像。这些
资源中的每一个都需要在CACHE中明确列出

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

表示必须包括所有CACHE标题下清单中的必要CSS,Javascript和图像文件。它与'NETWORK:*'不冲突,因为NETWORK标题 NOT 意味着'缓存所有内容'。它实际上意味着相反:NETWORK标题下的所有内容都需要互联网连接,不应该被缓存。

means that you must include all necessary CSS, Javascript and image files in the manifest under the CACHE heading. It does not conflict with 'NETWORK: *' because the NETWORK heading does NOT mean 'cache everything'. It actually means the opposite: that everything under the NETWORK heading requires an internet connection and should not be cached.

这篇关于HTML5缓存清单:后备部分&网络*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆