본문 바로가기

HTML

html5 - mainfest ( 네트워크가 끊어졌을 경우를 대비한 작업)

ht10_cache.html


<!DOCTYPE html>

<html manifest="ht10cache.manifest">

<head>

<meta charset="UTF-8">

<title>Insert title here</title>

<script type="text/javascript">

function support_cache(){

return window.applicationCache;

}

window.onload = function(){

if(support_cache()){

alert("어플리케이션케시 지원합니다.");

}else{

alert("어플리케이션 케시 지원하지 않음");

return;

}

}

</script>

</head>

<body>

<div class="my">Hello</div>

<img src="s1.png"/><br/>

<img src="s2.png"/>

</body>

</html>


==========================================================================================

10cache.mainfest


CACHE MANIFEST

#이건 주석


CACHE:

ht10.js

ht10.css

s1.png


NETWORK:

s2.png


==========================================================================================

web.xml

    <mime-mapping>

        <extension>manifest</extension>

        <mime-type>text/cache-manifest</mime-type>

    </mime-mapping>


==========================================================================================

html 파일에

manifest 확장자를 갖는파일을 만들어주고 다음과 같이 manifest 파일명을 작성해준다.

<html manifest="ht10cache.manifest">


CACHE: 에 설정되있는 파일이름을 명시해주면 클라이언트측에 저장이된다. 네트워크가 끊어졌을 경우 저장된파일을 사용

NETWORK: 에 설정되있으면 서버가 살아있을때만 사용가능

xml에서 manifest를 사용할 수 있게 맵핑해준다.