【发布时间】:2012-03-06 10:05:32
【问题描述】:
更新:
** 当这个功能真的很新时,我发布了这个问题,我现在意识到这个功能不应该以这种方式使用,除非它是通过 JavaScript 使用的。但对于大多数犯同样错误和滥用此功能的初学者来说,似乎这个 hack 是一个很好的解决方案。如果你想缓存除 HTML 之外的所有内容,这应该使用 JS 来完成,或者你可以使用下面的解决方案 **
我想我的问题可以归结为: 如果使用 HTML 标记的 manifest 属性引用清单的文件属于 MASTER CACHE ENTRIES,您如何让动态页面使用清单。
我的文件如下所示:
CACHE MANIFEST
CACHE:
# IMAGES:
/stylesheets/bg.jpg
/stylesheets/cont_bg.png
#and so forth..
#EXTERNAL
http://chat.mydomain.com/themes/images/panel_bg.png
http://chat.mydomain.com/themes/images/images_core.png
####################################
#STYLE SHEETS:
/stylesheets/min.css
/stylesheets/css_night.aspx
#####################################
#JAVASCRIPT:
/JAVASCRIPT/header_javascript.js
#EXTERNAL:
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js
http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
FALLBACK:
/ /offline.php
NETWORK:
*
现在的问题是,一旦我浏览一个不在清单中的页面,我的实际动态 php 文件(如 index.php),当我第一次看到该页面并且没有缓存 chrome 时:
Adding master entry to Application Cache with manifest http://208.109.248.197/manifest.appcache
Application Cache Downloading event
Application Cache Progress event (0 of 28)
...
Application Cache Progress event (28 of 28)
Application Cache NoUpdate event
到目前为止一切顺利,直到我真正加载了一个页面,并且 chrome 运行:
Application Cache UpdateReady event
Adding master entry to Application Cache with manifest http://mydomain.com/manifest.appcache
现在正如您在最后一行中看到的那样,它将 index.php 添加到我的应用程序缓存中,我已经通过访问 url 验证了这一点:chrome://appcache-internals/
上面写着:
Flags URL Size (headers and data)
Explicit, http://mydomain/JAVASCRIPT/header_javascript.js 57.5 kB
Master, http://mydomain/home.php 51.2 kB
Master, http://mydomain/index.php 53.5 kB
Master, Fallback, http://mydomain/offline.php 49.4 kB
像 index.php 和 home.php 这样的东西不应该被缓存。如果可能,我想告诉它不要缓存任何 html 扩展。但这是我从各种 RFC 中学到的东西,我相信: 在线白名单通配符标志,打开或阻止。
The open state indicates that any URL not listed as cached is to be implicitly treated as being in the online whitelist namespaces; the blocking state indicates that URLs not listed explicitly in the manifest are to be treated as unavailable.
好吧,我想使用这些在线白名单通配符标志之一并将其设置为阻止,但我找不到更多解释或示例。 我也读过:
zero or more URLs that form the online whitelist namespaces.
These are used as prefix match patterns, and declare URLs for which the user agent will ignore the application cache, instead fetching them normally (i.e. from the network or locale HTTP cache as appropriate).
我也想使用这样的模式,但我又找不到任何文档。为什么没有 appcache 清单文档的迹象,而且我去过的其他网站也没有使用它,因为我的 chrome appcache 目录没有显示!?!?
感谢您的宝贵时间!
【问题讨论】:
标签: manifest cache-manifest html5-appcache manifest.cache