iphone 离线缓存的应用程序在 safari 中关闭后消失?

发布于 2024-07-19 15:10:27 字数 662 浏览 6 评论 0原文

我们正在为 iPod touch/iPhone 开发一个 html5 离线 Web 应用程序。 我们的清单和一切工作正常,但我们无法弄清楚为什么我们的应用程序在 iphone safari 中的“选项卡”关闭后不会重新打开。

举个例子,工作原理如下:

1) 在 iPod touch 上的 safari 中打开启用离线功能的 html 文件的 url

2) 退出 safari,关闭 wifi

3) 返回 safari,其中动态 Web 应用程序位于窗口中,点击刷新

4) 应用程序可以离线使用!

但是,如果我们这样做,离线应用程序就会消失:

5) 将书签添加到应用程序的 URL(或主屏幕图标)

6) 关闭 Safari 中的“选项卡”或窗口

7) 打开书签或主屏幕图标

8 ) 错误消息:“无法打开页面:Safari 无法打开页面,因为它未连接到互联网。”

我已经用谷歌搜索了一下这个问题,你知道它是怎么回事,我会在点击“发布”后 2 秒找到答案..但无论如何,我的直觉是当前最新的 iphone 操作系统版本的 safari 正在尝试到 url 上的 dns 查找并出错,而不是意识到设备上已经有本地存储的应用程序。

有人遇到这个吗? 我可以在清单中设置一些标志或解决此问题吗?

We're developing an html5 offline webapp for the ipod touch/iphone. We have the manifests and everything working correctly, but we can't figure out why our app will not reopen after the 'tab' in iphone safari is closed.

For example's sake, here's what works:

1) open the url to the offline-enabled html file in safari on the ipod touch

2) exit safari, turn wifi off

3) go back into safari where the dynamic webapp is in a window, hit refresh

4) app works offline!

however, if we do this, the offline app dissapears:

5) add a bookmark to the app's url (or a home screen icon)

6) close the 'tab' or window in safari

7) open the bookmark or the home screen icon

8) error message: "Cannot Open Page: Safari cannot open page because it is not connected to the internet."

I've googled on the issue a bit, and you know how it goes, I'll find the answer 2 seconds after hitting 'post' here.. but anyway my gut feeling is that the current latest iphone OS version of safari is trying to dns lookup on the url and erroring out rather than realizing it has the locally stored app already on the device.

anyone run into this? is there some flag i can set in my manifest or something to fix this?

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

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

发布评论

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

评论(3

最终幸福 2024-07-26 15:10:27

Safari(以及 iPhone)似乎希望所有文件都列在清单中 - 甚至是应用程序的主文件。 我使用 default.asp 作为我的应用程序的主页,但未将其包含在清单中。 我的应用程序是从 mydomain.com/myapp/ 运行的,因此浏览器从未看到“default.asp”。 另外,根据 HTML5 规范,主页不需要在清单中,但显然 Safari 的看法略有不同。

我的解决方案是避免使用 default.asp 并调用我的应用程序 app.asp 并将“app.asp”添加到清单中。 希望这可以帮助。

It seems Safari (and thus the iPhone) expects all files to be listed in the manifest - even the main file of the app. I was using default.asp as the main page of my app and not including this in the manifest. My app was run from mydomain.com/myapp/ and thus the browser never saw the "default.asp". Also, according to the HTML5 spec, the main page need not be in the manifest but apparently Safari sees that a little differently.

My solution was to avoid using default.asp and calling my app app.asp and adding "app.asp" to the manifest. Hope this helps.

七颜 2024-07-26 15:10:27

您可能没有正确配置服务器。 苹果文档并没有明确说明这一点。

如果您的服务器正在运行 Apache(很可能),则需要编辑此文件:
/user/local/apache2/conf/mime.types

将此行添加到末尾:
text/cache-manifest manifest

您需要重新启动 Apache 才能使设置生效。 可能是这样的
从 shell 中restart_apache

这里发生的情况是服务器需要将缓存文件返回给您并设置正确的内容类型。 如果您不这样做,文件可能会以“文本”形式返回。 如果设置正确,它将返回一种“缓存清单”。

要测试返回的文档的 MIME 类型,请使用 web-sniffer.net。 输入清单文件的 url - 您将看到内容类型中显示的结果:

You probably do not have your server properly configured. The Apple docs do not make this clear.

If your server is running Apache (most likely), you need to edit this file:
/user/local/apache2/conf/mime.types

Add this line to the end:
text/cache-manifest manifest

You will need to restart Apache so the settings take effect. Could be something like
restart_apache from the shell.

What's happening here is that the server needs to return the cache file back to you with the proper content type set. If you don't do this, the file will probably come back as 'text'. If set properly, it will come back with a type of 'cache-manifest'.

To test what mime type a document is being returned as, use web-sniffer.net. Enter the url to your manifest file - you will see the result displayed in Content-Type:

心头的小情儿 2024-07-26 15:10:27

提示:检查是否每当您对清单中的文件进行更改时,您都会更改清单本身中的某些内容以指示需要下载这些文件。 并注意缓存的文件,这些文件可能不会根据其过期设置检查更改

Tip: Check that whenever you make changes to the files in the manifest that you change something in the manifest itself to indicate that those files need to be downloaded. And watch out for cached files that might not be checked for changes based on their expiration settings

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