doubei2340 2014-11-13 02:32
浏览 72
已采纳

检查每个请求到达apache web服务器

I have a weird requirement asked , to check time difference between each request and response

I have a PHP file (request.php) serving a image as it's response, so i have to check time difference between GET request.php and GET image request. for each and every request.

For example:

the time request.php is made lets say 12:40 AM

it will response a image, when image is inserted in a web page i get a image request say 12.42 AM.

so my requirement is to calculate time difference between request.php and image every time they hit my server.

I suggested to read Apache access-log but client want me to note request time for every request made and store some where and calculate average between each request on end of the day.

My idea is to read Apache-log and is there a way we can write a php script which will work for every incoming request and check it's timing, probably a custom access-log file.

Any Help!!

  • 写回答

2条回答 默认 最新

  • douxi1738 2014-11-13 03:53
    关注

    2:From your question, I gather that the requirement is to actually get the time that the image finally "shows up" on the visitor's browser?

    If that is the case, then, well this may get technical pretty quick, depending how accurate the info should be, and also if you don't mind getting the said images via XMLHTTpRequest - via JavaScript. If that is the case, you can do the whole server-side thing as a pre-requisite, aditionally, set a custom response header, i.e:

    header('x-imageID', $mysql_insert_id());
    

    Then readfile('blah.jpg');

    on the client-side, with the XMLHTTpRequest, set in the onload event another request to the server, with the image-id with e.g xhr.getResponseHeader('x-imageID') and the current time in milliseconds: new Date().getTime().

    obviously you will need to set some info to distinguish the requests so that the server will only log for image requests, and update the records with the "update time" requests.

    Hope it helps ;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么