2
爲什麼我的離線應用沒有被任何瀏覽器緩存?離線appcache無法正常工作
我已經在這裏創造一個簡單的測試: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>
哦。我的。 Goooddddd!我覺得自己像個白癡,因爲我只是在過去的一個小時裏爲此工作。 – Sirens 2014-09-04 01:17:05