javascript – How to avoid getting "stalled" by multiple browser requests?


My problem is that I have multiple ajax (total 10) to make requests to certain resources.

According to chrome (it also happens in other browsers):

Tail. (Queuing) The browser queues requests when:

  • There are higher priority requests.
  • There are already six TCP connections open for this source, which is the limit. Applies only to HTTP / 1.0 and HTTP / 1.1.
  • The browser is briefly allocating disk cache space.

Stuck. (Stalled) The request could be stopped for any of the reasons described in the queue .

In my case it is because there are more than 6 connections (10), "stalled" is added to the last 4, and the added time is equivalent (more or less) to the time of the 4 fastest queries that are sent in the first block of 6.

To look at it another way, there is a block of 6 requests and a queue of 4, and when a query for this block finishes, one of those that were in the queue is executed, like this until there are no queued requests.

Grouping ajax requests is not an option since the idea is to use JS asynchrony so that all requests are made at the same time and thus reduce times.

I am interested in a solution that can be compatible with IE9 +, but any answer that is only for more modern browsers is also welcome.

In the backend, the requests arrive at a serveResource method (from liferay) that I have overwritten, and depending on the type of resource that is requested by parameter, one resource or another is returned.

public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {
    String recurso = ParamUtil.getString(resourceRequest, "recurso");

My ajax are something like this:

    type: "POST",
    url: "/miPortlet?recurso=tartas&masParametros=todosIguales",
    dataType: 'json',
    beforeSend: funcionAntesDeAjax,
    success: function(data){

The url of the ajax varies only in one parameter recurso=tartas in each one is a different resource.

I have read the following thread in English: Chrome stalls when making multiple requests to the same resource? . Where it is said that this behavior is due to Chrome blocking the cache and waiting to see the result of a request before requesting the same resource again.

I have tried with different solutions commenting on that thread like:

  • Add headers to the request ( Cache-Control: no-cache, no-store or Cache-Control: no-store ) through headers and through the beforeSend .
  • Add cache: false with the ajax in post / get method
  • Add a random number as a parameter to differentiate the URL (it was already different)


A possible solution is to group the requests in groups of 6. In jQuery the $.ajax function returns a promise, which allows you to group and wait for all of them to be resolved, using the $.when method, before continuing to execute the code. Example:

var request1 = $.get("");
var request2 = $.get("");
var request3 = $.get("");
var request4 = $.get("");
var request5 = $.get("");
var request6 = $.get("");

).done(function (response1, response2, response3, response4, response5, response6) {

  console.log("GROUP 1");

  var request7 = $.get("");
  var request8 = $.get("");
  var request9 = $.get("");
  var request10 = $.get("");

  ).done(function (response7, response8, response9, response10) {
    console.log("GROUP 2");

In this article you can see a step by step of using $.ajax with $.when :

Here you can also find the documentation for those methods:

Finally, I want to tell you that if your platform receives many requests in parallel, you may run into a bottleneck on the side of your http server or your pool of connections to the database. In that case you should find some way to scale your backend .

Scroll to Top