我正在运行DHTML页面,希望缓存引用的HTML,PHP文件和IMAGE文件。
我在WWW.sitename.COM/sub-dir /
中有以下所有文件的.htaccess
AddType application/x-httpd-php .html
AddType application/x-httpd-php .htm
AddType text/cache-manifest .manifest
AddHandler server-parsed .html
AddHandler application/x-httpd-php .html .htm
cache.manifest
CACHE MANIFEST
# Cache manifest version 0.0.00002
NETWORK:
CACHE:
http://WWW.sitename.COM/sub-dir/index.html
http://WWW.sitename.COM/sub-dir/this.php
http://WWW.sitename.COM/sub-dir/images/first.png
http://WWW.sitename.COM/sub-dir/images/second.png
FALLBACK:
THIS.PHP文件中的HTML清单引用...
<html manifest="http://WWW.sitename.COM/sub-dir/cache.manifest">
用于检测缓存活动的脚本
<script type="text/javascript">
var cacheStatusValues = [];
cacheStatusValues[0] = 'uncached';
cacheStatusValues[1] = 'idle';
cacheStatusValues[2] = 'checking';
cacheStatusValues[3] = 'downloading';
cacheStatusValues[4] = 'updateready';
cacheStatusValues[5] = 'obsolete';
var cache = window.applicationCache;
cache.addEventListener('cached', logEvent, false);
cache.addEventListener('checking', logEvent, false);
cache.addEventListener('downloading', logEvent, false);
cache.addEventListener('error', logEvent, false);
cache.addEventListener('noupdate', logEvent, false);
cache.addEventListener('obsolete', logEvent, false);
cache.addEventListener('progress', logEvent, false);
cache.addEventListener('updateready', logEvent, false);
function logEvent(e)
{
var online, status, type, message;
online = (navigator.onLine) ? 'yes' : 'no';
status = cacheStatusValues[cache.status];
type = e.type;
message = 'online: ' + online;
message+= ', event: ' + type;
message+= ', status: ' + status;
if (type == 'error' && navigator.onLine)
{
message+= ' (probably a syntax error in cache.manifest)';
}
console.log(message);
}
window.applicationCache.addEventListener(
'updateready',
function(){
window.applicationCache.swapCache();
console.log('swap cache has been called');
},
false
);
setInterval(function(){cache.update()}, 10000);
</script>
控制台报告没有缓存任何内容。
感激地收到任何和所有的帮助。
谢谢。
答案 0 :(得分:7)
经过大量研究,答案是......
请勿包含包含
的网页的名称html manifest =“cache.manifest”
cache.manifest文件中的标记。
确保cache.manifest文件仅使用相对URL而不是ABSOLUTE。
确保您的iPad在系统软件更新后至少重启一次。
.htaccess文件中清单文件的正确MIME类型是
AddType text / cache-manifest .manifest
感谢Bjorn在dev.bjorn.com/723帮助我到达那里......一篇值得一读的好博客文章。