防止离线应用程序加载时 HTML5 applicationCache 检查事件

发布于 2024-11-16 10:49:04 字数 434 浏览 4 评论 0原文

我有一个 HTML5/jquery 移动网络应用程序,位于 http://app.bluedot.mobi。它用于长距离比赛,通过 SPOT 卫星跟踪来跟踪参赛者。我尚未解决的问题是,在不存在数据连接的情况下加载应用程序时,浏览器会在检查事件期间尝试获取清单时抛出“无数据连接”警报弹出窗口。即使存在数据连接,加载应用程序也可能需要很长时间。有大约 500 个文件需要检查。 (从手机)加载应用程序的最快方法是处于飞行模式并关闭浏览器的警报 - 不太优雅。

我不想强制那些经常处于连接不稳定的偏远地区的用户进行更新,而是希望以编程方式使用 applicationCache.update() ,让用户能够控制流程并加快应用程序加载速度,无论是在线还是离线。

目前 HTML5 规范和相应的浏览器实现可以实现这一点吗?

I have an HTML5/jquery mobile web app at http://app.bluedot.mobi. It is used for long distance races to track competitors via SPOT satellite tracking. The issue I have not yet resolved is that when loading the app when no data connection exists, the browser throws a "no data connection" alert popup as it is attempting to fetch the manifest during the checking event. Even when a data connection is present, loading the app can take a very long time. There are ~ 500 files to check. The fastest way to load the app (from a phone) is to be in airplane mode and dismiss the browser's alert - not so elegant.

Rather than force an update on users who tend to be in the backcountry with a spotty connection, I want to use applicationCache.update() programmatically, giving the user control over the process and speeding up app load whether on or offline.

Is this currently possible with the HTML5 spec and respective browser implementations?

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

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

发布评论

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

评论(2

盗梦空间 2024-11-23 10:49:04

听起来你需要 abort( ) 方法。不幸的是,它非常新,可能需要一段时间才能被大多数移动浏览器实现。

Sounds like you need the abort() method. Unfortunately it is very new, and it will probably be a while before it is implemented by the majority of mobile browsers.

深海少女心 2024-11-23 10:49:04

大约有 500 个文件需要检查。

听起来您似乎在暗示浏览器检查每个文件以查看是否有任何文件已更改。这是不正确的。浏览器仅检查清单文件是否已更改,这是一个简单的字节检查。如果清单文件没有更改,则浏览器认为没有任何更改。

因此,如果您的应用程序启动缓慢,可能是因为您的应用程序很复杂并且有大量的 HTML 和 Javascript 需要解析。我建议您查看一下该应用程序,看看是否有任何可以优化的地方。在这种情况下,您可能需要查看雅虎的加速网站速度的最佳实践页面。

例如,我注意到 HEAD 部分有很多 Javascript 代码。前面提到的文章建议我们将所有Javascript(尽可能)移至页面底部,以便浏览器可以尽快开始渲染页面。文章中还有很多其他合理的建议。那么请看一下,我相信您会发现它很有用。 :-)

There are ~ 500 files to check.

It sounds like you're implying that the browser checks each file to see if there's any of them which has changed. This is not correct. The browser only checks the manifest file if that has changed, and that is a simple byte check. If the manifest file has not changed, the browser believes nothing has changed.

So if your application is slow to start, it might be your because your application is complex and there's alot of HTML and Javascript to parse. I would advise you to take a look at the application and see if there's anything you can optimize. In that case, you might want to take a look at Yahoo's Best Practices for Speeding Up Your Web Site page.

For example, I noticed you have a lot of Javascript code in the HEAD section. The beforementioned article advices us to move all Javascript (To the extent of what's possible) to the bottom of the page, so that the browser can start rendering the page as soon as possible. And there's a lot of other sound advice in the article. So take a look, I'm sure you'll find it useful. :-)

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