In my C# dotnet desktop application, I use restclient lib to call my https API, the first call after user logon always requires more than 10 seconds! I have tried everything I can find by google:
try
{
// Equal to: ipconfig /flushdns
bool res = Win32API.DnsFlushResolverCache();
_log.InfoFormat("DnsFlushResolverCache returns {0}", res);
}
finally
{
//nothing to do.
}
System.Net.WebRequest.DefaultWebProxy = null;
System.Net.HttpWebRequest.DefaultWebProxy = null;
System.Net.ServicePointManager.Expect100Continue = false;
client = new RestClient(endpoint);
client.Proxy = null;
client.BaseHost = server_host;
client.AddDefaultHeaders(headers);
// ignore certificate trust
client.RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
client.Timeout = _restClientTimeout;
... //url is https://192.168.1.1/api/xxx
DateTime beginat = DateTime.Now;
IRestResponse response = client.Execute(request);
TimeSpan span = DateTime.Now.Subtract(beginat);
_log.InfoFormat("timespan: {0} seconds.", span.TotalSeconds)