为什么我的离线应用程序没有被任何浏览器缓存?
我在这里创建了一个简化的测试:http: //design.aqueo.us/test/appcache/
它只有两个文件:一个 html 文件加上清单。(html 文件包含一些用于显示缓存状态的 javascript。)检查控制台日志,您会看到它总是显示“缓存状态:未缓存”。chrome://appcache-internals/(在 Google Chrome 中)也没有列出该站点。据我所知,浏览器甚至从不获取清单文件。我已经在多个浏览器中尝试过了。
这是清单:
CACHE MANIFEST
# .
这是HTML:
<!doctype html>
<html>
<head manifest="offline.appcache">
<meta charset="utf-8">
<title>Appcache test</title>
<script>
(function() {
var webappCache = window.applicationCache;
function loaded()
{
var h1El = document.querySelector("h1");
var connectionStatus = ((navigator.onLine) ? 'online' : 'offline');
h1El.textContent = h1El.textContent + " - currently: " + connectionStatus;
switch(webappCache.status)
{
case 0:
console.log("Cache status: Uncached");
break;
case 1:
console.log("Cache status: Idle");
break;
case 2:
console.log("Cache status: Checking");
break;
case 3:
console.log("Cache status: Downloading");
break;
case 4:
console.log("Cache status: Updateready");
break;
case 5:
console.log("Cache status: Obsolete");
break;
}
}
function updateCache()
{
webappCache.swapCache();
console.log("Cache has been updated due to a change found in the manifest");
}
function errorCache()
{
console.log("You're either offline or something has gone horribly wrong.");
}
window.addEventListener("load", loaded, false);
webappCache.addEventListener("updateready", updateCache, false);
webappCache.addEventListener("error", errorCache, false);
})();
</script>
</head>
<body>
<h1>Appcache Test</h1>
</body>
</html>