2012-07-06 1 views
2

오프라인 앱이 어떤 브라우저에서도 캐시되지 않는 이유는 무엇입니까? 하나의 HTML 파일 플러스 매니페스트 : http://design.aqueo.us/test/appcache/오프라인 appcache가 작동하지 않습니다.

그것은 단지 두 개의 파일입니다 :

여기 간단한 테스트를 만들었습니다. (html 파일에는 캐시 상태를 표시하는 일부 javascript가 포함되어 있습니다.) 콘솔 로그를 확인하면 "Cache status : Uncached"라는 메시지가 나타납니다. 또한 chrome : // appcache-internals/(Google 크롬의 경우) 사이트가 표시되지 않습니다. 내가 알 수있는 한, 브라우저는 매니페스트 파일을 가져 오지 않습니다. 나는 여러 브라우저에서 이것을 시도했다.

여기 매니페스트의 :

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> 

답변

8

이럴수가! 모든 디버깅과 헤어 아웃 아웃 후에, HTML 엘리먼트가 아닌 HEAD 엘리먼트에 manifest 속성이 있습니다! 모든 바보 같은 실수!

링크가 예상대로 작동합니다.

업데이트 : 그냥 여기 상황이 분명하게 HTML 파일의 상단이 어떻게 보일지되는 :

<!doctype html> 
<html manifest="offline.appcache"> 
<head> 
+1

오. 나의. Goooddddd! 나는 그저 과거의 시간을이 일에 사용했기 때문에 그런 바보 같은 기분이 든다. – Sirens