<!DOCTYPE html> <html manifest="example.appcache"> <head> <title></title> <script type="text/javascript" src="test.js"></script> <script type="text/javascript" src="test2.js"></script> </head> <body> <script> // http://www.html5rocks.com/zh/tutorials/appcache/beginner/ // Check if a new cache is available on page load. document.addEventListener('load', function (e) { window.applicationCache.addEventListener('updateready', function (e) { if (window.applicationCache.status == window.applicationCache.UPDATEREADY) { // Browser downloaded a new app cache. // Swap it in and reload the page to get the new hotness. window.applicationCache.swapCache(); if (confirm('A new version of this site is available. Load it?')) { window.location.reload(); } } else { // Manifest didn't changed. Nothing new to server. } }, false); }, false); </script> </body> </html>
example.appcache文件中
CACHE MANIFEST
#2013-12-11
test.js
test2.js
在apache中
AddType text/cache-manifest .appcache