One excellent tool for helping to diagnose this is curl
along with a --write-out
format and the -I
and -L
flags.
If you use the -I
option curl will provide the response headers for each completed request.
The -L
flag will make sure that curl follows redirects.
The -w"@/path/to/format/file.txt"
flag will allow you to specify a format file that provides a plethora of information about the final request, including some fantastic timing information. This granular timing information can help you diagnose where in the request process the delay is being introduced.
- Notice that your
time_appconnect
time is excessively long? It could
be that your webserver is having an issue with SSL stapling.
- What about a long
time_namelookup
? Check to ensure that dns resolution
is quick.
- Is
time_redirect
taking forever? Maybe you should check
out what's preventing redirects from working properly.
- etc etc etc
Here is an example format that you can use with curl:
https://gist.github.com/manifestinteractive/ce8dec10dcb4725b8513
And here is an example of a request to google using that format and the options I explained above:
➜ ~ curl -IL -s -w"@sniff.txt" google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Mon, 24 Aug 2020 01:24:17 GMT
Expires: Wed, 23 Sep 2020 01:24:17 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Date: Mon, 24 Aug 2020 01:24:18 GMT
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked
Expires: Mon, 24 Aug 2020 01:24:18 GMT
Cache-Control: private
Set-Cookie: 1P_JAR=2020-08-24-01; expires=Wed, 23-Sep-2020 01:24:18 GMT; path=/; domain=.google.com; Secure
Set-Cookie: NID=; expires=Tue, 23-Feb-2021 01:24:18 GMT; path=/; domain=.google.com; HttpOnly
============= HOST: ==========
local_ip: 127.0.0.1
local_port: 65084
remote_ip: redacted
remote_port: 80
======= CONNECTION: ==========
http_version: 1.1
http_code: 200
http_connect: 000
num_connects: 2
num_redirects: 1
redirect_url:
============= FILE: ==========
content_type: text/html; charset=ISO-8859-1
filename_effective:
ftp_entry_path:
size_download: 0
size_header: 1013
size_request: 154
size_upload: 0
speed_download: 0.000
speed_upload: 0.000
ssl_verify_result: 0
url_effective: http://www.google.com/
=== TIME BREAKDOWN: ==========
time_appconnect: 0.000000
time_connect: 0.137004
time_namelookup: 0.136557
time_pretransfer: 0.137063
time_redirect: 0.596540
time_starttransfer: 0.409782
----------
time_total: 1.006389
For more information about what you can squeeze out of the curl format configuration, read the --write-out
part of the manual page:
https://curl.haxx.se/docs/manpage.html
Also of note, I'm not sure if you can do this reliably on Windows. I think it is possible to run curl on Windows, but I've never once attempted to do so so YMMV there. I very highly recommend using a Linux distro instead.