adarsh hegde adarsh hegde - 1 month ago 16
Java Question

Firefox and IE slow for 302 status redirect requests

I have a servlet-jsp web app. One of the requests in the login action is taking upto 120 sec to complete on Firefox and IE browsers. However this same request is completed normally in chrome (below 1 sec). On debugging the code I can conclude that my web app filter is returning the response quickly but the browser shows it took 120 sec to receive it. If you see the firefox developer tool below, it shows the waiting time to be 360ms and the receiving time as 120
s approx. This same behavior can be seen on IE also. Any clue what might be causing this?

enter image description here

EDIT 1: This issue is being observed only for requests that return a 302 response code.

EDIT 2: I tried using an intercepting tool to check the requests, for this I had to route the traffic through a proxy at (localhost) . One observation is that while doing this the application is significantly faster. A possible explanation I observed for this is the proxy application returns the 302 requests with a status code of 200 to the browser. So now the question is why are 302 calls slow on the Firefox and IE browser?


Finally was able to resolve this issue from my app itself. In one of the places in the code the flush operation was being called upon the output stream of the response.


This was only being done in cases when the request was not of type 302 which makes sense because 302s don't have any data in the response. Chrome is smart enough to see that and doesn't wait expecting any data. However, firefox and IE keep waiting for the data and thus the connection for that particular call is not closed. This causes the delay which can be seen in the image I attached in the question (browser tries to download content which never arrives).

I have now changed the code to do the flush operation for 302s calls also. This has resolved the entire problem.