【发布时间】:2012-10-11 22:33:19
【问题描述】:
我找不到像我这样的另一个问题,所以这里是:
我有这个缓存清单文件:
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!为什么?我正在使用铬。
另一个问题是 Firefox,当我尝试这个时,我有:0 items in offline cache
有人可以解释一下吗,我在搜索的所有地方都没有看到类似的问题
【问题讨论】:
-
您可以查看浏览器正在缓存哪些文件。只需更改哈希即可。完成后,您应该在 Chrome 中加载新站点并查看控制台中缓存了哪些文件。
-
hash 是用 md5_file() php 函数自动生成的,所以如果文件改变了,hash 也会改变。这不是问题,问题是为什么我下线时永远无法到达offline.html。
-
根据规范,您的服务器还应发送带有日期的过期标头,以便缓存文件,如果我理解正确,您是否在您的网络服务器中进行了配置?
-
是的,我在 apache2.conf 中配置了一些东西,但没有为 text.html 类型配置:ExpiresActive on ExpiresByType text/css A2592000 ExpiresByType application/x-javascript A2592000 ExpiresByType text/javascript A2592000 ExpiresByType image/jpeg A2592000 ExpiresByType image/png A2592000 ExpiresByType image/gif A2592000 ExpiresByType text/js A2592000
-
尝试添加
text/html和application/xhtml+xml以及
标签: html caching manifest offline fallback