2011-11-12 31 views
1

我找不到在哪裏有人不希望把所有的網址,在網絡的任何情況:部分:HTML5 appcache:NETWORK:部分的真正用途是什麼?

NETWORK: *

如果資源不在CACHE:部分,也不在NETWORK:部分中,資源將不會被加載。但是如果一個資源不在CACHE中:但是在NETWORK:部分中,至少它會在用戶在線時加載!

+0

正要問同樣的問題。也許用'NETWORK'節可以以某種方式取代其他節中的設置。但是,另一方面,指定'*'可以工作,並且不會阻止緩存資源在脫機模式下提供服務。真的,'NETWORK'部分對我來說似乎是多餘的。 – feklee

+0

做了一些閱讀,發現它是關於安全性的:查看我的答案。 – feklee

回答

3

NETWORK部分允許你,你信任白名單唯一的資金來源。這是一項安全措施。因此,它也適用於純在線應用程序,即不使用其他兩個部分的應用程序(CACHE,FALLBACK)。

報價從MDN(如2012年10月28日CEST,重點通過我的):在應用程序緩存

網絡條目基本上是一個「白名單在線」 -URIs在網絡部分指定的從服務器加載而不是緩存。 這可以讓瀏覽器的安全模型通過限制對已批准資源的訪問來防止潛在的安全漏洞。

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.