服务器发起的通信
每当您请求网页时,您都会向服务器发送一条消息,然后服务器会做出响应。据我所知,大多数交互都是这样发生的:客户端向服务器说一件事,服务器回说一件事。服务器无法“在与人交谈之前说话”。
是否有任何技术可以让服务器发起对话?例如,如果您有一个想要始终保持最新的页面,那么我现在要做的就是定期发出 AJAX 请求以从服务器获取更新的信息。然而,如果服务器能够在新信息可用时让客户端知道,那就更好了。周围有什么东西可以做到这一点吗?
Whenever you request a web page, you send a message to a server, and the server responds. As far as I know, most interaction occurs this way: the client says one thing to the server, and the server says one thing back. The server can't "speak until spoken to".
Are there any technologies that let the server initiate a conversation? For instance, if you had a page that you wanted to always keep up to date, the way I'd do it now is periodically make an AJAX request to get updated info from the server. However, it would be nicer if the server could just let the client know at the moment when new info was available. Is there anything around that can do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找的概念是推送技术。
The concept you are looking for is push technology.
所有HTTP交互都是客户端请求、服务器响应。为了摆脱您所描述的轮询更新,您必须查看 HTTP 之外的内容;要在网页中执行此操作,您必须使用插件、Java 小程序、ActiveX 控件等。
All HTTP interactions are client request, server response. To get away from polling for updates as you described, you would have to look outside of HTTP; to do this in a webpage, you would have to use a plugin, Java applet, ActiveX control, etc.