여기 오프라인으로 읽기 메커니즘을 사용하여 HTML5 모바일 앱을 만들 계획입니다.인터넷이 온라인 상태 일 때 HTML5가 캐싱되지 않음
인터넷에 연결되어있을 때 또는 표시 할 때 하나의 페이지에 동적 콘텐츠가 있습니다.
나는 메커니즘을 manifest으로 캐싱하고 있습니다.
온라인으로 동적 페이지를로드 할 때 처음으로 캐시 된 시간이며 인터넷에서 오프라인이되면 동적 페이지도 볼 수 있습니다.
그러나 문제는 인터넷 연결이 다시 돌아올 때 동적 페이지를 다시 호출해서는 안된다는 것입니다. 그러나 그것은 일어나지 않습니다. https://www.sitepoint.com/common-pitfalls-avoid-using-html5-application-cache/ - :
은 내가 예를 들어이 목적을 위해 많은 블로그와 사이트를 통해 갈 http://html5doctor.com/go-offline-with-application-cache/<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/cache-manifest "access plus 0 seconds"
</IfModule>
이 블로그에 파이어 폭스는 말했다 모질라에 대한 htaccess로 파일을 넣어했습니다.
아무렇지도 않게!
내 페이지는 다음과 같습니다
1) home.html을
<!DOCTYPE html>
<html manifest="dtt.appcache">
<body>
<p><button onClick="loadDoc(1)" type="button">home</button> || <button onClick="loadDoc(2)" type="button">centers</button> || <button onClick="loadDoc(3)" type="button">about us</button></p>
<!--<p><a href="home.html" >home</a> || <a href="centers.php" >centers</a> || <a href="about-us.html" >about us</a></p>-->
<div id="contentarea">
This is my home page.
</div>
<script>
function loadDoc(id) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("contentarea").innerHTML =
this.responseText;
}
};
if(id == '1'){
document.getElementById("contentarea").innerHTML =
'This is my home page'
} else if(id=='2'){
xhttp.open("GET", "centers.php", true);
xhttp.send();
}else if(id=='3'){
document.getElementById("contentarea").innerHTML =
'This is my about us page'
}
}
</script>
</body>
</html>
2) centers.php
<!DOCTYPE html>
<html manifest="dtt.appcache">
<body>
<?php echo time().'<br>';?>
</body>
</html>
3) dtt.appcache
CACHE MANIFEST
# 2003-12-01 v2.0.0
home.html
centers.php
about-us.html
내 요구 사항 인터넷 연결자처럼 간단합니다. 거기에는 오프라인 읽기 (일어나는 일)를 위해 캐시 된 페이지가 있어야하고 동적 콘텐츠 페이지에서 읽을 때마다 인터넷 연결이 있어야합니다.
위 예제에서 서비스 직원을 어떻게 활용할 수 있습니까? – rahul
지금 준비가되어있는 샘플이 없습니다. 하지만 아래 링크에서 아이디어를 얻을 수 있습니다. –
https://mobiforge.com/design-development/taking-web-offline-service-workers –