“持久连接"究竟是什么?意思是? [英] What exactly does a "persistent connection" mean?

查看:18
本文介绍了“持久连接"究竟是什么?意思是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过HTTP 持久连接",但不知何故我似乎不明白什么在这种情况下,持久意味着什么.
能详细点吗?

I read about "HTTP persistent connection" but somehow I don't seem to understand what does persistent mean in this context.
Could you'll elaborate?

推荐答案

到目前为止,所有讨论都来自浏览器方面.浏览器首先请求实际页面,然后解析页面并找出它需要的所有其他资源,然后才能呈现该页面.浏览器一一请求这些资源和其他依赖资源.因此,在这里维护持久连接非常有效,因为避免了创建和销毁连接的开销.

All the discussion till now has been from the browser side of things. The browser first request the actual page, and it parses the page and finds out all other resources that it needs before it can render that page. The browser requests these resources and other dependent resources one by one. So maintaining a persistent connection is very efficient here, as the overhead of creating and destroying connections is avoided.

现在从 Web 服务器端来看,持久连接将允许其将内容推送"到 Web 浏览器.现在 HTTP 不支持这个.因此,使用 javascript 的解决方法很少,页面基本上会在一段时间后刷新.

Now from web server side of things, a persistent connection would be one that allows it to "push" content to the web browser. Now HTTP doesn't support this. So, there are few workarounds with javascript where the page is basically refreshed after a while.

您可以看到许多基于 Web 的电子邮件提供商正在使用这种技巧,它们不断地在后台检查新邮件.这给人一种感觉,当有新邮件到达时,服务器会将新邮件通知推送"到 Web 浏览器.但实际上,它实际上是一个不断检查服务器是否有新邮件的网络浏览器.

You can see this being trick being used by many web based email providers which continuously keep checking in the background for new mails. This gives a feeling that when a new mails arrives, the server "pushes" the new mail notification to the web browser. But in fact, its actually the web browser which keeps on checking the server for any new mail.

还有一点我想说明的是,我们实际上看不到任何页面刷新,这是因为另一个技巧只允许请求刷新页面的特定部分.(提示:AJAX)

Also another point that I would like to state is that we actually don't see any page refresh that's because of another trick which allows only specific parts of the page to be refreshed by the request. (HINT: AJAX)

这篇关于“持久连接"究竟是什么?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆