HTML5 appcache:NETWORK:部分的真正用途是什么?

发布于 2024-12-15 07:50:08 字数 168 浏览 3 评论 0原文

我找不到任何人不想将其所有 URL 放入 NETWORK: 部分的情况:

NETWORK: *

如果资源不在 CACHE: 部分中,也不在 NETWORK: 部分中,则不会加载该资源。但是如果资源不在 CACHE: 中而是在 NETWORK: 部分中,那么至少在用户在线的情况下会加载它!

I can't find any case where someone doesn't want to put all their URLs in the NETWORK: section:

NETWORK:
*

If a resource isn't in the CACHE: section, nor in the NETWORK: section, the resource won't be loaded. But if a resource is not in CACHE: but is in the NETWORK: section, at least it will be loaded in the case the user is online!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾城°AllureLove 2024-12-22 07:50:08

NETWORK 部分允许您仅将您信任的资源列入白名单。这是一种安全措施。因此,它对于纯在线应用程序也很有用,即不使用其他两个部分(CACHEFALLBACK)的应用程序。

引自 MDN(截至 2012 年 10 月 28 日中欧夏令时间,我强调):

应用程序缓存中的网络条目本质上是一个“在线白名单”——NETWORK 部分中指定的 URI 是从服务器而不是缓存加载的。 这使得浏览器的安全模型可以通过限制对批准资源的访问来保护用户免受潜在的安全漏洞。

The NETWORK section allows you to white list only resources that you trust. It is a security measure. As such it is useful also for pure online apps, i.e. apps that do not make use the other two sections (CACHE, FALLBACK).

Quote from MDN (as of 2012-10-28 CEST, with emphasis by me):

Network entries in an application cache are essentially an "online whitelist"—URIs specified in the NETWORK section are loaded from the server instead of the cache. This lets the browser's security model protect the user from potential security breaches by limiting access to approved resources.

屌丝范 2024-12-22 07:50:08

是的,你是对的。以下是我找到的完美答案:-

 A manifest can have three distinct sections: CACHE, NETWORK, and FALLBACK.

CACHE:
This is the default section for entries. Files listed under this header (or immediately     after the CACHE MANIFEST) will be explicitly cached after they're downloaded for the first time.
NETWORK:
Files listed under this section are white-listed resources that require a connection to the server. All requests to these resources bypass the cache, even if the user is offline. Wildcards may be used.
FALLBACK:
An optional section specifying fallback pages if a resource is inaccessible. The first URI is the resource, the second is the fallback. Both URIs must be relative and from the same origin as the manifest file. Wildcards may be used.

Yes, you are correct. Below is the perfect answer i found:-

 A manifest can have three distinct sections: CACHE, NETWORK, and FALLBACK.

CACHE:
This is the default section for entries. Files listed under this header (or immediately     after the CACHE MANIFEST) will be explicitly cached after they're downloaded for the first time.
NETWORK:
Files listed under this section are white-listed resources that require a connection to the server. All requests to these resources bypass the cache, even if the user is offline. Wildcards may be used.
FALLBACK:
An optional section specifying fallback pages if a resource is inaccessible. The first URI is the resource, the second is the fallback. Both URIs must be relative and from the same origin as the manifest file. Wildcards may be used.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文