1

我正在玩 HTML 5 缓存清单,我在 Chrome 中看到了一个非常奇怪的问题。这是页面的标题:

<html id="html" xmlns="http://www.w3.org/1999/xhtml" manifest="Portal/CacheManifestHandler.ashx">

以下是从提琴手捕获的清单内容:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/cache-manifest; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 20 Apr 2012 15:56:20 GMT
Content-Length: 56

CACHE MANIFEST
NETWORK:
*
#Timestamp: 634705337615835020

我在页面的标题内有一个特定的脚本,该脚本是在服务器上动态生成的。以下是用户第一次访问该页面时为该脚本标签返回的内容:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/javascript; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 20 Apr 2012 15:36:33 GMT
Content-Length: 74

document.location='/Portal/Login.aspx?ReturnUrl=%2fPortal%2fDefault.aspx';

您可以看到脚本既不在 Cache-manifest 中,也不在其标头允许浏览器 (Chrome) 缓存它。仍然当我随后在浏览器中打开同一页面时,Chrome 会从缓存清单加载页面,这没关系。然而令人惊讶的是,它也从缓存中加载了 <script>。我可以验证它,因为我的服务器断点没有被命中,Fiddler 也没有显示对此 <script> 的请求。网络没有关闭并且服务器可以访问(这应该没有什么不同,因为 Chrome 被要求不要缓存这个 <script> 反正)。

这是预期的行为吗?Chrome 不应该再次从服务器请求 <script> ,即使它的包含页面是从清单缓存中加载的。

Chrome 的 chrome://appcache-internals 在缓存中也只显示了 2 个 url,这也很好,为什么它会从缓存而不是服务器加载 <script> Chrome 的 chrome://appcache-internals 在缓存中也只显示了 2 个 url,这也很好,为什么它会从缓存而不是服务器加载 <script>

4

1 回答 1

0

我们遇到了同样的问题,我们的解决方案是在 app.manifest 的网络部分添加 *,这样我们的网络部分看起来像

网络: *

我现在正在挖掘这是否真的是谷歌的“设计”,还是完全错误。

于 2012-09-28T14:16:52.257 回答