Search code examples
javascriptajaxperformancegoogle-chrome

Why first network call takes more time than subsequent ones?


I am trying to understand this behavior where first network call takes more than double of subsequent ones. I know that DNS resolving will not take more than 5-50ms and it happens only in the initial call. Considering this info, there shouldn’t be much difference in time taken for the first call and subsequent calls.

I have tested this behavior with some famous URLs in separate incognito windows for each with cache disabled and attached a few screenshots to support my observation below. Can anyone help me understand this behavior?

Note: The readings are taken in full speed internet connection

enter image description here

enter image description here

enter image description here

enter image description here


Solution

  • After a few experiments, I found out that Content Download (browser request steps) part of the request is speeding up 1.5-2 times This looks like a cause of TCP Slow Start algorithm

    As it states:

    modern browsers either open multiple connections simultaneously or reuse one connection for all files requested from a particular web server

    That might be the reason for the first request to be slower than others

    Also, @Vishal Vijay made a good addition:

    Making initial connection handshake to the server is taking time (DNS Lookup + Initial connection + SSL). Browsers are creating Persistent Connections for HTTP requests and keep it open for some time. If any request came in for the same domain within that time, the browser will try to reuse the same connection for faster response.