我有以下 list
CACHE MANIFEST
# cache-revision-29541
# cache-creation-date: Fri Dec 5 11:33:29 GMT 2014
CACHE:
app.html
NETWORK:
*
和下面的 app.html
<!DOCTYPE html>
<html manifest="app.manifest">
<head>
<title>cache test</title>
<script>
function checkCache() {
var appCache = window.applicationCache;
var logACEvent = function(e) {
console.log("Cache Event " + e.type + " Status: " + appCache.status);
}
appCache.addEventListener('error', logACEvent, false);
appCache.addEventListener('checking', logACEvent, false);
appCache.addEventListener('noupdate', logACEvent, false);
appCache.addEventListener('downloading', logACEvent, false);
appCache.addEventListener('progress', logACEvent, false);
appCache.addEventListener('updateready', logACEvent, false);
appCache.addEventListener('cached', logACEvent, false);
}
checkCache();
</script>
</head>
<body>
</body>
</html>
还有我的 .htaccess 条目(设置内容类型)
AddType text/cache-manifest .manifest
ExpiresByType text/cache-manifest "access plus 0 seconds"
我已验证服务器正在设置内容类型。
在 Safari 中,这会输出两条控制台消息
Cache Event checking Status: 2
Cache Event noupdate Status: 1
在 Chrome 中,这会输出
Cache Event checking Status: 2
Cache Event noupdate Status: 1
在 Firefox 中我得到 p>
Cache Event checking Status: 0
Cache Event error Status: 0
在 IE11 中我得到
(i) Resource doesn’t exist on the server: 'http://10.119.103.2/~adf/RMC2/release/beta/app.html'.
(i) AppCache Fatal Error
Cache Event error Status: 0
应用程序 URL 是“http://{host}/~adf/RMC2/release/beta/app.html” app.manifest 和 app.html 在同一个文件夹中。
没有指示可能是什么错误。我可以直接加载 IE 提示的 URL(它与用于加载应用程序的 URL 相同)。
about:cache 在 firefox 中甚至没有列出这个应用程序。
CACHE MANIFEST
app.html
即使使用上面的简单 list ,IE11 和 Firefox 也会报错,IE 在控制台中报 Manifest parse failure 错误。
HTML1300: Navigation occurred.
File: app.html
Creating AppCache with manifest: 'http://10.119.103.2/~adf/RMC2/release/beta/app.manifest'.
Cache Event checking Status: 0
Manifest parsing failure: 'http://10.119.103.2/~adf/RMC2/release/beta/app.manifest'.
AppCache Fatal Error
Cache Event error Status: 0
我做错了什么?
更新:
如果我在 ~adf/RMC2/...浏览器。
这是为什么?
最佳答案
在 Firefox 内置的应用缓存验证工具的帮助下,我最终解决了这个问题。
Shift+F2
appcache validate
这表明服务器正在为资源发送 no-store header ,这与它们在应用程序缓存中存在冲突。
从服务器上的 .htaccess 中删除了违规条目,缓存开始工作。
关于javascript - 应用程序缓存 list 未在 Firefox 中加载,在 Chrome 和 Safari 中正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27320038/