【问题标题】:HTML5 appcache: what is the NETWORK: section really for?HTML5 appcache:NETWORK: 部分的真正用途是什么?
【发布时间】:2012-10-28 15:20:02
【问题描述】:

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

网络: *

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

【问题讨论】:

  • 正要问同样的问题。也许使用NETWORK 部分可以以某种方式取代其他部分中的设置。但是,另一方面,指定* 有效,并且它不会阻止缓存资源在离线模式下提供服务。真的,NETWORK 部分对我来说似乎是多余的。
  • 做了一些阅读,发现它与安全有关:请参阅我的答案。

标签: html web-applications html5-appcache


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

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

     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.
    

    【讨论】:

      猜你喜欢
      • 2010-10-30
      • 2020-08-07
      • 2020-02-02
      • 2012-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-09
      相关资源
      最近更新 更多