【问题标题】:HTML5 appCache manifest referencing a directory's default document引用目录默认文档的 HTML5 appCache 清单
【发布时间】:2013-02-06 08:37:30
【问题描述】:

在我正在开发的一个 jQuery 移动网站中,我的锚标记以下列方式引用 url:

  • “/目录/”
  • "/目录/子目录/"

当然是引用:

  • "/directory/index.html"
  • "/directory/subdirectory/index.html"

所以在我的清单文件中我是否需要引用“根”版本?例如

CACHE MANIFEST

CACHE:
/directory/
/directory/index.html
/directory/subdirectory/
/directory/subdirectory/index.html

NETWORK:
*

FALLBACK:
/ /offline.html

或:

CACHE MANIFEST

CACHE:
/directory/index.html
/directory/subdirectory/index.html

NETWORK:
*

FALLBACK:
/ /offline.html

它是否自动知道“/directory/”等价于“/directory/index.html”等?好像不会。

【问题讨论】:

    标签: html cache-manifest html5-appcache


    【解决方案1】:

    缓存是根据 URL 键控的。浏览器在访问/directory/ 时获得的任何文件都是它将为该 URL 缓存的任何文件。但是它不会自动知道/directory/index.html 等同于/directory/,这只有您的服务器才能知道。如果您在清单中列出这两个 URL,那么这两个 URL 都将被缓存,即使它们最终证明是相同的。

    【讨论】:

    • 这就是我的假设。但让我感到困惑的是 FALLBACK 的行为不同。 //offline.html 基本上充当通配符。它没有找到的任何文件都会获得该离线页面,而不仅仅是“/”根路径。 “/404.html”、“/anyurl”都获取离线页面。
    • @Matt 因为回退不是下载的东西,它是一个要匹配的模式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-16
    • 2018-03-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-07
    • 2015-06-25
    • 2011-03-03
    相关资源
    最近更新 更多