N
N
Nikolai2016-10-28 22:58:48
Nginx
Nikolai, 2016-10-28 22:58:48

What causes delays when accessing a direct ip from a browser?

Hello.
Perhaps my question is very stupid, and most likely the problem is that I cannot formulate it correctly and attach it to any specific area in order to google it.
The bottom line is that when an iframe is connected in the browser, the source of which is not the domain, but ip, or when, for example, an ajax request also occurs to the ip address, and not to the domain, then some kind of delay periodically appears (defined in the browser as Waiting [TTFB ]). If immediately after the answer, I make a request to the same ip, then everything happens without delay, but after I wait for a certain period of time (for example, an hour), then the first request also occurs with a delay.
In the case of an iframe, I don’t know, but the ajax request goes to the nginx server. Moreover, it seemed to me that nginx immediately writes in the logs that the request has been completed, and the browser is still waiting for some time for some unknown reason.
In fact, this is not a problem, since it is clear that you connect the domain and everything is resolved. But I'm very interested to understand what causes such delays. Maybe at least I'll learn something :)
UPD. I will also add that it is very unlikely that the case is related to the work of the code, since this is the first thing I thought about and put logging of the request execution time in nginx, which in theory measures the time from the very beginning to the very end (and includes both the work of the interpreter , and everything else). And in the nginx logs, these slow requests are written as completed quickly.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikolay, 2016-10-30
@kolchan11

Thanks everyone for participating in the discussion!
In general, I have not yet fully figured it out, but this is definitely a problem with my computer (not even the network). And 90% of this is a problem in Kaspersky antivirus, which probably treats ip addresses more reverently and checks them longer. If I can pinpoint the source of the problem, I'll update the answer.

Александр Аксентьев, 2016-10-28
@Sanasol

на локалке?
На локалке может долго резольвиться подключение к базе в скриптах при использовании 127.0.0.1 вместо localhost. Или наоборот, не помню точно.
И тоже самое с самим сайтом может быть, разные варианты написания по разному открываются.

Алексей, 2016-10-28
@alsopub

In your case, the delay is most likely on the server side and is associated with caching information or terminating the interpreter workflows and creating a new one at the next request, if the connection is via https, then there may be some delays in checking the certificate.
Calling by domain name instead of IP will not change anything, it will only add a delay in resolving the name to the address.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question