本文介绍了iPad上的应用程序缓存将不缓存网站数据或页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行一个DHTML页面,想要缓存被引用的HTML,PHP文件和图像文件。

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

我在WWW.sitename.COM/sub-dir /

I have all the following files in WWW.sitename.COM/sub-dir/

的.htaccess

.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

# 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中THIS.PHP文件清单参考...

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.

感谢你。

推荐答案

经过反复研究,答案是...

After much research the answer is...

  1. 不包括持有

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

HTML清单=cache.manifest

html manifest="cache.manifest"

在cache.manifest文件标记。

tag in the cache.manifest file.

确保cache.manifest文件只使用相对URL不是绝对的。

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

确保你的iPad的任何系统软件更新后,已至少重新启动一次。

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

正确的MIME类型为.htaccess文件清单文件是

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

将AddType文本/缓存清单名为.manifest

AddType text/cache-manifest .manifest

由于比约恩在dev.bjorn.com/723帮助我那里......一个好的博客文章值得一读。

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

这篇关于iPad上的应用程序缓存将不缓存网站数据或页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 19:39