HTML5 appcache:什么是NETWORK:部分真的适合?

时间:2011-11-12 22:04:08

标签: html5 web-applications html5-appcache

我找不到任何人不想将所有网址放入网络的情况:部分:

NETWORK: *

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

2 个答案:

答案 0 :(得分:3)

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

引自MDN(截至2012-10-28 CEST,我强调):

  

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

答案 1 :(得分:1)

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

 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.