HTTP 并行请求和 AJAX/轮询

发布于 2024-08-17 13:06:50 字数 176 浏览 2 评论 0原文

好的,我们都知道大多数现代浏览器(无需调整)都设置为一次向单个域/子域发送 4 个并行 HTTP 请求,但是长轮询 AJAX 对此有何影响?

假设我有一个间隔 15 秒的长轮询。当浏览器在这 15 秒内等待响应时,这是否仍然会有效地消耗 4 条并行线之一,从而使任何新选项卡或页面加载仅向 3 个并行 HTTP 请求打开?

Okay, so we all know that most modern browsers (without tweaking) are set to 4 parallel HTTP requests at a time to a single domain/subdomain, but how does long-polling AJAX affect this?

Say I have a long-poll on a 15 second interval. While the browser is waiting for a response during those 15 seconds, does that still eat up one of the 4 parallel lines effectively making any new tabs or page loads open to only 3 parallel HTTP requests?

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

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

发布评论

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

评论(2

执手闯天涯 2024-08-24 13:06:50
  1. 它并不总是 4,通常是 2。
  2. 在许多浏览器中,它可以在客户端配置为更高的数字。
  3. 是的,它确实耗尽了并行连接之一。
  1. It's not always 4, often it's 2.
  2. It is configurable to a higher number on the client side in many browsers.
  3. Yes it does eat up one of the parallel connections.
爱*していゐ 2024-08-24 13:06:50

您可以通过 XHR 有 2 个并发请求。如果您使用更多,您可能会得到意想不到的结果。

使用请求队列处理 2 个以上的请求...每个请求都是在前一个请求结束后发出的...

一些流行的 JS 库实现了一个队列并且可以使用,或者您可以轻松创建一个。

You can have 2 concurrent requests via XHR..if you use more you might end up with unexpected results.

Use a Request Queue for more than 2 requests...each one being made after the previous one ends...

Some popular JS libraries implement a queue and can be used, or you could create one easily.

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