离线时无法在具有缓存清单的移动 Safari 中工作

发布于 2024-09-15 20:51:12 字数 712 浏览 5 评论 0原文

我正在为 iPhone 开发一个移动网站。我添加了一个缓存清单,并加载了离线功能所需的资源列表。清单文件具有正确的内容类型。如果查看文件的响应标头,内容类型为 text/cache-manifest。清单文件位于:

http://hoodisgood.clientsit.es/cache.manifest

站点可在此处查看(您需要在 iPhone(或模拟器)上查看,或者在将用户代理设置为 iPhone 的 Safari 上查看。

http://hoodisgood.clientsit.es/

查看该网站并将其添加到主屏幕后,我将 iPhone 设置为飞行模式,当我尝试查看该网站时,我无法查看该网站。我收到一条警告,指出它无法打开,因为我已在缓存清单文件中指定了脱机操作所需的所有文件。

如果我错了,请纠正我。缓存清单,即使设备在线,浏览器也不应该读取缓存的源吗?当我查看该网站时,我没有看到的照片会从服务器加载,就像我之前关闭并重新打开时那样。所查看的图像仍在从服务器加载。

我做错了什么吗?我检查并重新检查,一切似乎都是正确的,只是不确定为什么它不起作用。

谢谢。

I'm working on a mobile site for the iphone. I've added a cache manifest and loaded it with a list of resources needed for offline capability. The manifest file has the correct content type. If you view the response header for the file, the content type is text/cache-manifest. The manifest file is here:

http://hoodisgood.clientsit.es/cache.manifest

The site is viewable here (you'll need to take a look on your iphone (or simulator) or on Safari with user agent set to the iphone.

http://hoodisgood.clientsit.es/

After viewing the site and bookmarking it to the home screen, I set my iphone to airplane mode and when I try to view the site, I can't. I get an alert that it can't open because it's not connected to the internet. I've specified all the files I need for offline operation in the cache manifest file.

Also, correct me if I'm wrong, but with a cache manifest, shouldn't the browser read from the cached source even when the device is online? When I view the site, photos I haven't seen are loaded from the server, as it should be. When I close and reopen, previously viewed images are still loading from the server.

Am I doing something wrong? I checked and re-checked, everything seems to be correct, just not sure why it's not working.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

当梦初醒 2024-09-22 20:51:12

我确实注意到您的标签没有引用清单。

<html manifest="cache.manifest">

此外,您需要确保清单文件使用“text/cache-manifest”mime 类型。

还要确保清单具有 UTF-8 编码,而不是浏览器难以理解的编码。

我还建议您在 Chrome 中加载该网站。如果您检查 Chrome 中的开发者日志,Chrome 会编写非常有用的错误消息,指导您找到问题所在。

I did notice that your tag did not reference the manifest.

<html manifest="cache.manifest">

Additionally, you need to ensure that the manifest file uses the "text/cache-manifest" mime type.

Also make sure that the manifest has UTF-8 encoding, and not some encoding that the browser has a hard time understanding.

Also I can recommend that you load the site in Chrome. If you check the developer log in Chrome, Chrome will write very helpfull error messages that will guide you to where the problem lies.

甜心 2024-09-22 20:51:12

我确实注意到您的标签没有引用清单。

<html manifest="cache.manifest">

此外,您需要确保清单文件使用“text/cache-manifest”mime 类型。

I did notice that your tag did not reference the manifest.

<html manifest="cache.manifest">

Additionally, you need to ensure that the manifest file uses the "text/cache-manifest" mime type.

从来不烧饼 2024-09-22 20:51:12

我遇到了类似的问题:

尝试在清单文件中引用绝对路径。这对我来说很有效,而且我也使用了子域。

还可以在 Safari 中启用开发者控制台并添加以下 JS,

function logEvent(event) {
  console.log(event.type);
}
window.applicationCache.addEventListener('checking', logEvent, false);
window.applicationCache.addEventListener('noupdate', logEvent, false);
window.applicationCache.addEventListener('downloading', logEvent, false);
window.applicationCache.addEventListener('cached', logEvent, false);
window.applicationCache.addEventListener('updateready', logEvent, false);
window.applicationCache.addEventListener('obsolete', logEvent, false);
window.applicationCache.addEventListener('error', logEvent, false); 

这样您就可以检查浏览器中的缓存清单发生了什么情况,并了解是否发生错误。

I had a similar problem:

Try referencing absolute paths in your manifest file. This did the trick for me and I as well was using a sub domain.

Also enable your developer console in Safari and add the following JS

function logEvent(event) {
  console.log(event.type);
}
window.applicationCache.addEventListener('checking', logEvent, false);
window.applicationCache.addEventListener('noupdate', logEvent, false);
window.applicationCache.addEventListener('downloading', logEvent, false);
window.applicationCache.addEventListener('cached', logEvent, false);
window.applicationCache.addEventListener('updateready', logEvent, false);
window.applicationCache.addEventListener('obsolete', logEvent, false);
window.applicationCache.addEventListener('error', logEvent, false); 

Like this you can check what happens in regards to your cache manifest in the browser and learn if an error occurs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文