后备缓存清单不起作用

时间:2012-10-22 06:24:18

标签: html5 caching manifest offline fallback

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

我有这个缓存清单文件:

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!为什么?我正在使用chrome。

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

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

2 个答案:

答案 0 :(得分:2)

./online.html部分下方有CACHE:。删除它,您的网络应用程序应检索offline.html。您在断开连接时获取online.html的原因是因为您正在缓存它。

答案 1 :(得分:0)

我自己正在努力解决这个问题:

  1. 您必须先清除缓存
  2. 重新加载您的信息页
  3. 再次重新加载(声音愚蠢,我知道),然后将使用该文件的新版本,并且 在课程中再次缓存。
  4. 然后保持这种语法:

    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必须是相对的,并且与清单文件的来源相同。可以使用通配符。

相关问题