Application Caching on iPad will not cache website data or pages

核能气质少年 提交于 2019-12-12 08:16:49

问题


I am running a DHTML page and want to cache the HTML, PHP file and IMAGE files that are referenced.

I have all the following files in 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:

HTML manifest reference in THIS.PHP file...

<html manifest="http://WWW.sitename.COM/sub-dir/cache.manifest">

script to detect cache activity

<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>

The console reports that nothing is being cached.

Any and all assistance gratefully received.

Thank you.


回答1:


After much research the answer is...

  1. DO NOT include the names of the pages that hold the

    html manifest="cache.manifest"

    tag in the cache.manifest file.

  2. Ensure the cache.manifest file only uses relative URLs not ABSOLUTE.

  3. Ensure your iPad had been rebooted AT LEAST once after any system software update.

  4. The correct MIME type for the manifest file in the .htaccess file is

    AddType text/cache-manifest .manifest

Thanks to Bjorn at dev.bjorn.com/723 for helping me get there... a good blog post worth reading.



来源:https://stackoverflow.com/questions/16002355/application-caching-on-ipad-will-not-cache-website-data-or-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!