离线时无法在具有缓存清单的移动 Safari 中工作
我正在为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我确实注意到您的标签没有引用清单。
此外,您需要确保清单文件使用“text/cache-manifest”mime 类型。
还要确保清单具有 UTF-8 编码,而不是浏览器难以理解的编码。
我还建议您在 Chrome 中加载该网站。如果您检查 Chrome 中的开发者日志,Chrome 会编写非常有用的错误消息,指导您找到问题所在。
I did notice that your tag did not reference the 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.
我确实注意到您的标签没有引用清单。
此外,您需要确保清单文件使用“text/cache-manifest”mime 类型。
I did notice that your tag did not reference the manifest.
Additionally, you need to ensure that the manifest file uses the "text/cache-manifest" mime type.
我遇到了类似的问题:
尝试在清单文件中引用绝对路径。这对我来说很有效,而且我也使用了子域。
还可以在 Safari 中启用开发者控制台并添加以下 JS,
这样您就可以检查浏览器中的缓存清单发生了什么情况,并了解是否发生错误。
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
Like this you can check what happens in regards to your cache manifest in the browser and learn if an error occurs.