现代 Web 应用程序的离线和套接字选项有哪些?

发布于 2024-12-21 18:49:59 字数 545 浏览 7 评论 0原文

所以我一直在考虑构建一个相当复杂的应用程序。构建 html5 版本的想法已经成为一个相当有吸引力的可能性。不过,我首先有几个问题。

我首先关心的是目前离线应用程序 API 的可靠性如何。我一直在研究这个标准: http://www .whatwg.org/specs/web-apps/current-work/multipage/offline.html 它看起来很容易实现和使用,但我想知道它有多容易使用?假设您设置了清单等,Web 应用程序是否只是通过转到您最初下载应用程序的同一 URL 来访问(离线)?

我的另一个担忧是套接字的使用。这个离线应用程序仍然需要能够与本地服务器通信,理想情况下我希望避免托管网络服务器,但是套接字连接是可行的。目前,当浏览器离线时,Websocket 的工作效果如何?即使没有有效的互联网连接,是否也可以运行完全联网/交互式浏览器应用程序? (首次下载应用程序后)

任何见解都会很棒!

So I have been thinking about building quite a complex application. The idea of building an html5 version has become quite an attractive possibility. I have a few questions about it first however.

My first concern is how reliable the offline application API's are at the moment. I have been looking into this standard: http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html and it looks pretty easy to implement and use, but I am wondering how easy it is to use? And assuming you set up the manifest etc, is the web application just accessed (offline) by going to the same url you originally downloaded the application from?

My other concern is the use of sockets. This offline application still needs to be able to communicate with local servers, I ideally wanted to avoid having to host a web-server, a socket connection however would be plausible. How well do websockets currently work when the browser is offline? Is it possible, to have a fully networked / interactive browser application running even without an active internet connection? (after the app is first downloaded)

Any insight would be great!

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

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

发布评论

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

评论(1

赏烟花じ飞满天 2024-12-28 18:49:59

这是很多问题,您可能需要考虑将其分解为更容易回答的部分,这些部分与您想要实现的目标更直接相关。与此同时,我将尝试对您的每个问题提供简短的回答:

我首先关心的是离线应用程序 API 的可靠性如何
那一刻。

它们相当可靠,已在大多数主要网络浏览器(IE 除外)的多个版本中实现

是刚刚通过访问相同的地址访问(离线)的 Web 应用程序
您最初下载该应用程序的网址?

是的。一旦离线应用程序被缓存,应用程序就会从该缓存中提供服务。除非您明确从清单的 NETWORKFALLBACK 部分请求 URL,或者清单根本不包含这些 URL,否则不会发出任何网络请求,除了检查是否清单本身已经改变。

这个离线应用程序仍然需要能够与
本地服务器,我理想地希望避免托管网络服务器,
然而,套接字连接是可行的。

Web Socket 仍然需要 Web 服务器。 Web 套接字的初始握手是通过 HTTP 进行的。 Web Socket 与 TCP/IP 中的套接字不同

当浏览器离线时,Websocket 目前的工作效果如何?

它们根本不起作用,当您将浏览器设置为离线模式时,它根本不会发出任何网络请求。请注意,浏览器设置为离线与“offline API”中的离线不同。离线 API 主要关心是否可以访问托管应用程序的服务器,而不是浏览器当前是否连接到网络或该网络是否连接到互联网。如果服务器出现故障,那么应用程序就会“离线”,就像用户计算机上的网线被拔掉一样。请仔细阅读这篇博文,尤其是评论。我检测离线状态的常用方法是在 FALLBACK 部分中设置一对文件,以便您在在线时获得一个文件,在离线时获得另一个文件 - 使用 AJAX 请求该文件并查看您获得的内容。

是否有可能拥有一个完全联网/交互式的浏览器
即使没有有效的互联网连接,应用程序也能运行吗?

是的,但我认为这并不意味着你所认为的那样。在不同计算机上的不同浏览器上运行的应用程序的单独实例如果不通过 Web 服务器就无法相互通信。然而,不要求 Web 服务器“在互联网上”,它在本地网络上就可以很好地工作。

That's a lot of questions, you may want to consider breaking it up into more easily answerable portions more directly related to what, exactly, you're trying to achieve. In the meantime I'll try to provide a short answer to each of your questions:

My first concern is how reliable the offline application API's are at
the moment.

Fairly reliable, they have been implemented for a number of versions across most major web browsers (except IE).

is the web application just accessed (offline) by going to the same
url you originally downloaded the application from?

Yes. Once the offline app has been cached, the application is served from that cache. No network requests will be made unless you explicitly request URLs from the NETWORK or FALLBACK sections of the manifest or aren't covered by the manifest at all, apart from to check whether the manifest itself has changed.

This offline application still needs to be able to communicate with
local servers, I ideally wanted to avoid having to host a web-server,
a socket connection however would be plausible.

A Web Socket still requires a web server. The initial handshake for a Web Socket is over HTTP. A Web Socket is not the same thing as a socket in TCP/IP.

How well do websockets currently work when the browser is offline?

They won't work at all, when you've set a browser to offline mode it won't make any network requests at all. Note that a browser being set to offline is not the same thing as the offline in 'offline API'. The offline API is primarily concerned with whether or not the server hosting the application can be reached, not whether the the browser is currently connected to a network or whether that network is connected to the internet. If the server goes down then the app is just as 'offline' as if the network cable on the user's computer got unplugged. Have a read through this blog post, in particular the comments. My usual approach to detecting offline status is to set up a pair of files in the FALLBACK section such that you get one when online and the other when offline - request that file with AJAX and see what you get.

Is it possible, to have a fully networked / interactive browser
application running even without an active internet connection?

Yes, but I don't think that means what you think it does. Separate instances of the app running on different browsers on different machines would not be able to communicate with each other without going via the web server. However, there's no requirement that the web server be 'on the internet', it will do just fine sitting on the local network.

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