【问题标题】:cache.manifest works first time then failscache.manifest 第一次工作然后失败
【发布时间】:2011-05-21 02:54:36
【问题描述】:

我正在尝试将 html 5 缓存添加到 Web 应用程序,没有什么太复杂的只是图像/css/js。

当我在编辑 cache.manifest 文件后加载页面时,我在 Chrome 8 中得到以下调试:

Creating Application Cache with manifest http://example.com/themes/zenmobile/cache.manifest
Application Cache Checking event
Application Cache Downloading event
Application Cache Progress event (0 of 26) http://example.com/themes/zenmobile/plugins/img/toolbar.png
Application Cache Progress event (1 of 26) http://example.com/themes/zenmobile/plugins/img/greenButton.png
Application Cache Progress event (2 of 26) http://example.com/themes/zenmobile/plugins/jqtouch.transitions.js
Application Cache Progress event (3 of 26) http://example.com/themes/zenmobile/plugins/img/back_button_clicked.png
Application Cache Progress event (4 of 26) http://example.com/themes/zenmobile/plugins/img/button.png
Application Cache Progress event (5 of 26) http://quizible.com/sites/all/modules/jquery_update/replace/jquery.min.js
Application Cache Progress event (6 of 26) http://example.com/themes/zenmobile/plugins/img/grayButton.png
Application Cache Progress event (7 of 26) http://example.com/themes/zenmobile/plugins/img/chevron_circle.png
Application Cache Progress event (8 of 26) http://example.com/themes/zenmobile/plugins/img/on_off.png
Application Cache Progress event (9 of 26) http://example.com/themes/zenmobile/plugins/jqtouch.js
Application Cache Progress event (10 of 26) http://example.com/themes/zenmobile/layout.css
Application Cache Progress event (11 of 26) http://example.com/themes/zenmobile/plugins/img/chevron.png
Application Cache Progress event (12 of 26) http://example.com/themes/zenmobile/plugins/img/rowhead.png
Application Cache Progress event (13 of 26) http://example.com/themes/zenmobile/zenmobile.css
Application Cache Progress event (14 of 26) http://example.com/themes/zenmobile/plugins/img/loading.gif
Application Cache Progress event (15 of 26) http://example.com/themes/zenmobile/plugins/img/redButton.png
Application Cache Progress event (16 of 26) http://example.com/themes/zenmobile/plugins/img/activeButton.png
Application Cache Progress event (17 of 26) http://example.com/themes/zenmobile/images/bg_body.png
Application Cache Progress event (18 of 26) http://example.com/themes/zenmobile/plugins/theme.css
Application Cache Progress event (19 of 26) http://example.com/themes/zenmobile/plugins/img/toggle.png
Application Cache Progress event (20 of 26) http://example.com/themes/zenmobile/plugins/img/whiteButton.png
Application Cache Progress event (21 of 26) http://example.com/themes/zenmobile/plugins/img/toggleOn.png
Application Cache Progress event (22 of 26) http://example.com/themes/zenmobile/plugins/jqtouch.css
Application Cache Progress event (23 of 26) http://example.com/themes/zenmobile/plugins/img/button_clicked.png
Application Cache Progress event (24 of 26) http://example.com/themes/zenmobile/plugins/img/back_button.png
Application Cache Progress event (25 of 26) http://example.com/themes/zenmobile/plugins/img/blueButton.png
Application Cache Progress event (26 of 26) 
Application Cache Cached event

当我再次刷新页面时,所有 css/images/js 都无法加载并且控制台日志喷出:

Document was loaded from Application Cache with manifest http://example.com/themes/zenmobile/cache.manifest
Application Cache Checking event
Application Cache NoUpdate event

然后加载'加载资源失败'

除了这个输出之外,我没有找到任何有用的东西来尝试解决这个问题。有人见过这个吗?

【问题讨论】:

  • 您的 cache.manifest 文件中是否声明了任何 FALLBACK 资源?
  • 不,没有后备资源。

标签: web-applications html


【解决方案1】:

遇到了同样的问题。把它放在底部为我修复了它:

NETWORK:
*

为了解决大多数人在清单更新方面遇到的问题,这种方法对我来说非常有效:

在 url 中附加 manifest 文件和所有缓存的资源的版本号,并将 manifest 的内容设置为引用该版本号。像这样:

<html manifest="path/to/cache.manifest?v=42">

CACHE MANIFEST
#rev ?v=42

/css/foo.css?v=42
/css/bar.css?v=42
/js/script.js?v=42

我已为我们自动执行此操作,因此在进行新部署时,我只需将数字加 1(在我读取的设置文件中的某个位置),它在所有提到的文件中都会受到影响。每个浏览器请求不仅会检测清单文件的更改,还会导致重新加载(和缓存)提到的每个资源,从而更新整个应用程序。

【讨论】:

    【解决方案2】:

    html5 清单很难处理。如果它可以在一个浏览器中运行,它可能无法在另一个浏览器中运行

    1) 在您的资源选项卡中查看导致错误的资源(使用 firebug 或 webkit)
    2) 我发现每次部署都更改清单名称有助于确保浏览器检测到更改。

    【讨论】:

      【解决方案3】:

      您是否正在加载清单文件中没有的其他资源?尝试将它们全部列出,看看是否仍然存在问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-28
        • 2010-12-14
        • 2015-04-16
        • 1970-01-01
        • 2011-05-09
        • 2014-04-27
        相关资源
        最近更新 更多