I just need to know why is there so much lag before executing first line of code which is at the top of my webpage. I have a website with following structure. There is no line above this echo statement in PHP header. My header.php is like this:
<?php
echo (microtime(true) - $_SERVER['REQUEST_TIME']).'<br>';
//Do rest of stuff in header.
?>
This is my footer.php. There is no line below the echo in footer.:
<?php
//Do some stuff in footer.
echo (microtime(true) - $_SERVER['REQUEST_TIME']).'<br>';
?>
Just to be clear the webpage is rendering quickly in about 3/100 of a second. The problem is initial lag before I have done any processing in PHP or have output anything else. Now, the line from top in the header echos something like : 0.292453.. or 0.78583.. and the bottom line echoes something like: 0.29687... or 0.789939.. .So, as you can see PHP processes the webpage in about 0.004 seconds. My question is why does it take so much time in the beginning? How can I reduce it if it is possible? Does the beginning time include everything from the time the webpage is requested like resolving DNS, connecting and up until receiving?
Could anyone tell me why this question was downvoted? I will try to rephrase the question so that it makes more sense.