phpmysqlsmartyxajax

smarty loading time too long when LAN has no internet connection


I have the following situation:

I was developing an administrative web system using PHP Smarty and Xajax. I had no problems or issues when developing other than usual mistakes when writing the code, but I was fixing those issues on the go.

The LAN where the DB and Apache servers are have internet access and the behaviour of the website was the expected.

Two days ago the LAN I was working on was blocked to access the internet in order to test other system behaviour and trying to reproduce future production environment, and I noticed that the system I was working on, right from that moment on had a very long loading time, it loads but it takes quite a while, about 30 seconds or more, when before, with internet access, it was loading instantly.

After noticing this, I told the network admin to allow this LAN access to internet again, and the loading time was back to normal, after that that LAN was again without internet, and again the loading time was very long.

My smarty configuration that is in an included file in every php file is:

$smarty = new Smarty();
$smarty->cache_lifetime = 300;
$smarty->template_dir = "templates";
$smarty->compile_dir = "lib/smarty/templates_c";
$smarty->cache_dir = "lib/smarty/cache";
$smarty->config_dir = "lib/smarty/configs";

since I have Mysql server and Apache server in an internal LAN there shouldn't be any connectivity issues, so why is this happening?

I was hoping that anyone that had faced similar situation could give me any hint on why is this happening and how to solve it.


Solution

  • It was not related to Smarty.

    I solved this situation by preventing dns lookup in the mysql server.

    [mysqld]
    # Skip reverse DNS lookup of clients
    skip-name-resolve
    

    Now with or without internet connection from inside or from outside the LAN, it loads fast and well.