2

我找不到像我这样的另一个问题,所以这里是:

我有这个缓存清单文件:

CACHE MANIFEST

CACHE: 
./index.html
./offlinetest.js
./offline.html
./cache.manifest
./cache.manifest.php
./online.html

# Hash: 800d285afdd44dae60eb95bf479a94bf

NETWORK:
./index.html
./online.html

FALLBACK:
./index.html ./offline.html
./online.html ./offline.html

当我关闭 wifi 开关并且尝试访问 online.html 时,此文件将被提供而不是offline.html!为什么?我正在使用铬。

另一个问题是 Firefox,当我尝试这个时,我有: 0 items in offline cache

有人可以解释一下吗,我在搜索的所有地方都没有看到这样的问题

4

2 回答 2

2

你有./online.html下的CACHE:部分。删除它,您的 Web 应用程序应该会检索到 offline.html。断开连接时获得 online.html 的原因是因为您正在缓存它。

于 2012-10-31T20:51:02.677 回答
0

我自己也在为此苦苦挣扎,解决方案:

  1. 你必须先清除缓存
  2. 重新加载您的页面
  3. 再次重新加载(听起来很愚蠢,我知道),然后将使用文件中的新版本,并再次缓存。

然后保持这个语法:

FALLBACK:
//static.html will be served if main.py is inaccessible
/main.py /static.html
//offline.jpg will be served in place of all images in images/large/
images/large/ images/offline.jpg
// offline.html will be served in place of all other .html files
*.html /offline.html

一些可以帮助你的更多信息:

FALLBACK:如果资源不可访问,则指定后备页面的可选部分。第一个 URI 是资源,第二个是回退。两个 URI 必须是相对的,并且与清单文件来自同一来源。可以使用通配符。

于 2012-10-22T07:40:04.720 回答