Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Chrome to close/re-open all TCP/TLS connections when profiling with the Network Panel

The Network Panel of Chrome's DevTools is great for seeing how long different requests took to load in. It profiles each request and reports how long different parts of the request took, including the time spent making the initial TCP connection and SSL handshake:


(source: google.com)

When I load a page the first time I see the time taken for the initial connection and SSL handshake. If I immediately reload the page I no longer see any time spent on the initial connection and SSL handshake. I assume this is because Chrome has held open the TCP connection from the previous requests and is re-using it. That's great for normal browsing, but it makes profiling the initial page load difficult.

Is there any way I can force Chrome to not re-use any existing TCP/TLS connections and always make new ones?

If not in Chrome, is there something I can do at the OS level to achieve this? I'm on Windows, if it makes a difference.

like image 904
Michael Kropat Avatar asked May 11 '16 18:05

Michael Kropat


1 Answers

Chrome checks its socket pools to see if there is an available socket for the hostname, which it may be able to reuse - keep-alive sockets are kept in the pool for some period of time, to avoid the TCP handshake and slow-start penalties. If no socket is available, then it can initiate the TCP handshake, and place it in the pool. Then, when the user initiates the navigation, the HTTP request can be dispatched immediately. -- High Performance Networking in Google Chrome

Navigate to chrome://net-internals#sockets in order to see the active sockets. If you click 'Close idle sockets', the next time you refresh your page, it will establish a new connection instead.

I'm not sure there is a way to tell Chrome to disable the Connection: keep-alive header, but I think you could using a Chrome Extension like Modify Headers for Google Chrome to intercept the header sent from the client and remove it before the request reaches the server.

like image 83
Gideon Pyzer Avatar answered Oct 21 '22 13:10

Gideon Pyzer