donglu8549 2015-11-14 12:24
浏览 9

为什么要花一些时间来执行第一行网页?

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?