html - iPad 上的应用程序缓存不会缓存网站数据或页面

标签 html ipad .htaccess caching manifest

我正在运行一个 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 

缓存 list

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 list 引用...

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

控制台报告未缓存任何内容。

非常感谢收到的任何和所有帮助。

谢谢。

最佳答案

经过大量研究,答案是...

  1. 不要包含包含

    的页面的名称

    html list ="cache.manifest"

    在 cache.manifest 文件中标记。

  2. 确保 cache.manifest 文件仅使用相对 URL 而不是绝对 URL。

  3. 确保您的 iPad 在任何系统软件更新后至少重新启动一次。

  4. .htaccess 文件中 list 文件的正确 MIME 类型是

    AddType text/cache-manifest .manifest

感谢 dev.bjorn.com/723 上的 Bjorn 帮助我实现目标……一篇值得一读的好博文。

关于html - iPad 上的应用程序缓存不会缓存网站数据或页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16002355/

相关文章:

iphone - iOS 项目设置 : several apps slightly different between them. 几个目标

php - mod_deflate 和 zlib output_compression 的区别

php - 基于 HTTP :X-FORWARDED-FOR 允许在 htaccess 中访问

php - 防止直接 url 访问 php 文件

html - 线性渐变不同颜色的位置

javascript - 在 angularjs 组件中使用 Bootstrap 网格

ios - iOS 设备之间的 TCP 连接

html - 表格单元格的 CSS 选择器,在前一个单元格中检查了输入

javascript - &lt;/script&gt; 标签放置在错误的位置

ipad - 网站 JPG 在 iPad 上显得非常像素化