4

We all know that we should minify our JS, CSS and sprite our images. Not only to reduce the size being sent, but also to reduce the number of HTTP requests being sent. And that's what my question is about - what is the reason for limiting parallel AJAX requests by browsers (https://stackoverflow.com/a/14768266/769384 - more details on the limitations)?

AJAX is asynchronous, we don't know when it finishes. The more we parallelize, the less we'd have to wait. Limiting number of requests makes the initial page loading more synchronous-alike, since we have to wait, blocked, until the AJAX slots become free to be used again.

I do have some thoughts on that - but I'd really appreciate a good explanation.

Community
  • 1
  • 1
ducin
  • 25,621
  • 41
  • 157
  • 256
  • 2
    It seems you haven't noticed that limitation is **per domain**. There is no limit to different domains' requests. The reason for per domain limitation is [obvious](https://en.wikipedia.org/wiki/Denial-of-service_attack) – hindmost Sep 19 '16 at 19:13
  • 1
    @hindmost if it's obvious for you then I can't ask such question, no matter that it's not obvious for me, and so I ask... right? If everybody knew all *obvious* facts then nobody would ask. People like you make stackoverflow useless. – ducin Sep 20 '16 at 16:35
  • The problem is that you haven't read the linked question attentively: browsers actually don't limit **total** number of requests (only per domain). So your question looks misleading. BTW: I didn't downvote, neither voted for close. – hindmost Sep 21 '16 at 07:47
  • Possible duplicate of [Why can browsers only download two or four components in parallel?](https://stackoverflow.com/questions/10282107/why-can-browsers-only-download-two-or-four-components-in-parallel) – Andrew Grimm Jul 03 '17 at 23:16

1 Answers1

2

Browsers limit the number of parallel connections to

improve HTTP response times and avoid congestion

This is recommended in the HTTP 1.1 Specfication:

A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.

More practically, while perhaps convenient for load testing, not imposing a hard limit can degrade browser performance, and even cause an unintended DoS attack (or your client incorrectly being classified as a DoS attacker by the server).

Sensei James
  • 2,617
  • 30
  • 36