HTML5 appCache清单引用目录的默认文档

时间:2011-12-14 22:04:55

标签: html5 cache-manifest html5-appcache

在我正在研究的jQuery移动网站上,我有以下列方式引用网址的锚标记:

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

当然是引用:

  • “/目录/ index.html中”
  • “/目录/子目录/ index.html中”

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

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”等吗?好像不会。

1 个答案:

答案 0 :(得分:6)

根据URL键入缓存。浏览器在访问/directory/时获取的任何文件都是它将为该URL缓存的任何文件。但是,它不会自动知道/directory/index.html等同于/directory/,这只是您的服务器可以知道的事情。如果您在清单中列出这两个网址,则两个网址都会被缓存,即使它们结果相同。