0

I've deployed a webserver using Nginx. The webserver is under a virtual machine using Virtualbox. Everything seems to work properly. Connections are carried out on a local network context.

The problem is that my webpages under the webserver always take 5 seconds to load the first time I'm accessing the webpage. After the initial access, when I reload the page or access again, the webpage shows up instantly. I've disabled browser caching already. Then if I wait for around a minute, the process repeats: when I try to load a webpage it takes 5 seconds.

I'm getting the same behaviour on Edge Chromium and Firefox. I tried with Safari (MacOs) and I'm not getting that behaviour but I believe Safari is using memory caching even if I disabled it.

Up to this point, I'm not sure what it could be. Browsers? Nginx? DNS?

My virtual machine is not sleeping. I've tried changing DNS servers on system preferences. I'm using custom hosts to access my websites hosted on my server (/etc/hosts). I'm using Debian 9 as a server and MacOS Big Sur 11.1 as my host machine.

I'm also using PHP but I tried both pages: plain HTML and PHP and both have the same result.

This problem is making my work a nightmare, since after every change I have to wait for 5 seconds to see the changes.

  • 1
    Open your browser's web developer tools and look at the timings. – Michael Hampton Feb 25 '21 at 18:21
  • @MichaelHampton I've already done that. That's why I know it takes exactly 5 seconds to load. I'm using Chromium DevTools. – ProtectedVoid Feb 25 '21 at 18:21
  • I don't see it anywhere in your post. Did I miss something? – Michael Hampton Feb 25 '21 at 18:30
  • "I'm using custom hosts to access my websites hosted on my server (/etc/hosts)." Make sure there are no DNS queries at the beginning of your browsing, as your description and the 5s seems a lot like DNS timeouts... It also depends of your local DNS resolution works (local resolver or not, using systemd-resolverd or not, etc.) – Patrick Mevzek Feb 25 '21 at 20:03

1 Answers1

0

I was using ".local" domain name for my local projects, defined in /etc/hosts. Somehow my machine was trying to resolve that domain with a 5 seconds timeout. After that timeout the page loaded properly. Solved it by changing to another domain. This is weird because I've been using ".local" domain name for a while now, but on Windows environment and never had a problem. It looks like this is different on MacOS.

  • Yes the TLD `.local` -- which you didn't say in your question -- is special and used for MDNS (aka Bonjour) which is implemented by MacOS and sometimes Unix but not Windows; see https://superuser.com/questions/1359738/how-are-names-resolved-on-modern-local-networks and related https://unix.stackexchange.com/questions/286195/how-do-i-figure-out-where-wrong-local-dns-results-are-coming-from . BTW if you try `.dev` Chrome forces that to HTTPS=secure (via HSTS preload); there are existing Qs on that also. – dave_thompson_085 Feb 28 '21 at 10:16
  • @dave_thompson_085 I didn't mention it, because I didn't think it was relevant since it wasn't a problem before. Thank you for the extra information. – ProtectedVoid Mar 04 '21 at 16:00