“持久连接”到底是什么?意思是?

发布于 2024-08-06 01:44:28 字数 151 浏览 5 评论 0原文

我读到了“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?

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

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

发布评论

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

评论(3

叹沉浮 2024-08-13 01:44:28

这意味着服务器在完成推送响应后不会关闭套接字(因此必须通过标头或分块以其他方式指示响应的长度),以便客户端可以在同一套接字上发出其他请求。网页通常会请求与页面本身位于同一服务器上的多个其他部分(图像、CSS、脚本等),因此与关闭服务器相比,重用套接字来处理对同一服务器的某些进一步请求可以减少总体延迟。原始套接字并为所有后续请求打开新套接字。

It means the server doesn't close the socket once it's finished pushing out the response (so the length of the response has to be otherwise indicated, via headers or chunking), so the client can make other requests on the same socket. A web page often requests several other pieces (images, CSS, scripts, ...) on the same server as the page itself, so reusing the socket for some of those further requests to the same server can reduce overall latency compared to closing the original socket and opening new ones for all the follow-on requests.

篱下浅笙歌 2024-08-13 01:44:28

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

现在,从 Web 服务器方面来看,持久连接将允许其将内容“推送”到 Web 浏览器。现在 HTTP 不支持这个。因此,JavaScript 几乎没有解决方法,页面基本上会在一段时间后刷新。

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

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

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.

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.

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.

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)

心凉怎暖 2024-08-13 01:44:28

我认为这是网站浏览器http或https的切换。如果您有旧的 https:// 并且现在使用 http 作为浏览器 .htaccess 文件,那么这个问题应该通过 yoast 插件一页抓取页面创建。不用担心这不是重要的错误。对于黑客来说,如果您的 ssl 连接为空,这是一种攻击您网站的方法,他们应该将页面或域附加到您的 ssl 连接
eb http://www.example.com 以及当您浏览 https://www.example.com 在浏览器中还有一些其他链接可以打开您的网站域。

解决方案始终使用您的网站完整地址:为保护您的网站免受黑客攻击,请为您的网站使用 ssl 和 https:// 页面。

那么这个问题在任何测试站点或页面中都不会出现。

I think this is a switching for http or https for website browser. If you have old https:// and you are now using http for browser .htaccess file then this problem should created via yoast plugins one page crawl page. don't worry about it is not important error. For hackers this is a way to hack your website if your ssl connection is empty they should attach there page or domain to your ssl connection
e.b http://www.example.com and when you brows https://www.example.com in browser there are some other link with open your site domain.

Solution for this always use your full address for website: to protect hackers against your website use ssl and https:/ page for your website.

Then this problem have never scene in any test site or page.

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