2014-04-10 1 views
1

HTML5 애플리케이션 캐시를 사용하는 오프라인 애플리케이션이 있습니다. 대부분의 경우 그것은 훌륭하게 작동합니다. 여러 대의 기기 (데스크톱, IOS, Android 등)에서 앱에 액세스하는 일부 고객이 있습니다.캐시 Manifest 업데이트가 'ondownloading'이벤트에서 중단됩니다.

초기 문제는 유지 보수 또는 기타 용도로 클라이언트의 웹 서버가 다시 시작될 때마다 일부 장치. 방금 런타임 서버 오류가 발생했습니다. 서버를 다시 시작할 때 시작시 캐시 매니페스트 파일을 실용적인 방식으로 업데이트하여이 문제를 해결할 수있었습니다. 서버를 다시 시작하면 일부 장치에서 캐시 업데이트가 필요한 이유를 알 수 없었지만 나중에 작동하기 위해 다시 작동하도록했습니다.

이제 새로운 문제가 있습니다. 서버가 다시 시작될 때 일부 Android 기기는 캐시를 업데이트하지 않습니다. 캐시 매니페스트가 서버를 다시 시작하지 않고 수동으로 업데이트되는 경우 캐시는 정상적으로 업데이트되지만 서버가 다시 시작되면 '청취자 확인'및 '리스닝 수신기'중에 Androids가 예상대로 작동하지만 '진행 리스너'로 이동하지 않습니다. 오류 '오류 수신기'로 넘어 가지 않습니다. 그러면 오류 처리 기능을 완료 한 후 중지됩니다.

내 코드는 다음과 같습니다. 아래 코드는 모두 외부 js 파일에 있고 registerCacheMethod는 aspx 프로젝트의 마스터 페이지 헤드에서 호출됩니다.

var updatePhase = 'none'; 
    var cacheCount = -1; 


    function handleCacheUpdated() 
    { 
     updatePhase = 'handleCacheUpdated()'; 
     $('#modal_body_progress').html('Cache Updated Successfully'); 

     alert('The application was updated. Login required.'); 

     window.location.href = 'Login.aspx'; 
    } 


function handleOnDownloading() 
{ 

      updatePhase = 'Downloading'; 

      $('#modal_body_Header').html('Cache Update'); 

      $('#modal_body_text').html('Please do not close the browser or navigate away from this page while updating.'); 


      $('#modal_body_progress').html('Updating...'); 

      $('#modal_popup_container').css('display','inline'); 

      cacheCount = 0; 

    return false; 
} 
function handleOnProgress() 
{ 
    updatePhase = 'Progress'; 
    cacheCount++; 
    $('#modal_body_progress').html('Updating Entry: ' + cacheCount); 
    return false; 
} 
function handleCacheError(e) 
{ 
    $('#modal_body_progress').html('Error Loading Entry: (Count: ' + cacheCount + ', Phase: ' + updatePhase + ')'); 


    return false; 
} 

    function handleNoUpdate() 
    { 
     updatePhase = 'No Update'; 
    } 
    function handleChecking() 
    { 
     updatePhase = 'Checking'; 
    } 
    function handleCacheObsolete() 
    { 
     updatePhase = 'CacheObsolete'; 
    } 

function registerCacheMethods(method) 
    { 

     try 
     { 
      var cache = window.applicationCache; 
      if (cache == undefined) 
      { 
       alert('This browser does not support Application Cache'); 
       return false; 
      } 
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
      /* 
      * Between the poll and registering of the event you might miss the CACHEREADY event. This block will handle this. 
      */ 
      if (cache.status === applicationCache.UPDATEREADY) 
      { 
       handleCacheUpdated(); 
       return false; 
      } 
      cache.addEventListener('updateready', handleCacheUpdated, false); 
      ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
      cache.addEventListener('cached', handleCacheUpdated, false); 
      cache.addEventListener('noupdate', handleNoUpdate, false); 
      cache.addEventListener('downloading', handleOnDownloading, false); 
      cache.addEventListener('progress', handleOnProgress, false); 
      cache.addEventListener('error', handleCacheError, false); 
      cache.addEventListener('obsolete', handleCacheObsolete, false); 
      cache.addEventListener('checking', handleChecking, false); 
     } 
     catch (EX) 
     { 
      return false; 
     } 
    } 

편집

나는 이것에 대한 좀 더 많은 정보를 찾을 수 있었다. 1 번 문제가있는 장치와 브라우저를 찾았습니다. 이 문제는 삼성 Galaxy S3에서 실행되는 Android 4.3에서 발생합니다. 이 새로운 정보를 통해 누군가 이미 비슷한 질문을 한 것을 알았습니다. Here

답변

0

IIS (또는 사용하는 웹 서버) 구성 문제가 여기 있다고 생각합니다. 먼저 첫 번째 다시 시작 문제를 무시하면 기본적으로 새로운 오류가 발생하는 새 문이 열립니다. 아마도 각 브라우저 유형마다 다른 동작을하는 것일 수 있습니다. 초점을 맞추어 조언 해주세요. 처음부터 문제가 다시 시작되었습니다. 그리고 내가 잘못하지 않았다면 웹 서버 나 (클라이언트의 웹 서버)가 * .appcache 파일이 만료되도록 만료 헤더를 설정하도록 구성해야합니다. & 파일을 수동으로 캐시해서는 안됩니다. 아파치에 대해서는이 지시어가 작동합니다.

ExpiresByType text/cache-manifest "access plus 0 seconds"