检查每个请求来apacheweb服务器 [英] check every request coming to apacheweb server

查看:294
本文介绍了检查每个请求来apacheweb服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的规定要求,检查每个请求和响应

之间的时间差

我有一个PHP文件(request.php)供应的图像,因为它的响应,所以我要检查GET request.php之间的时间差和获取图像的要求。对于每一个请求。

例如:

时request.php是由可以说上午十二时40分

它会回应一个图像,当图像被插入在网页中我得到一个图像请求说,上午12时42分。

所以我的要求是,每次他们打我的服务器计算request.php和图像之间的时间差。

我建议阅读Apache的访问日志,但客户要我注意申请时间尽一切请求,并在那里存放了一些,并计算在这一天结束时每个请求之间的平均水平。

我的想法是读取Apache的日志,并在那里我们可以写一个PHP脚本,将工作的每一个进来的请求,并检查它的时机,可能是一个自定义的访问日志文件的方式。

任何帮助!!

解决方案

2:从你的问题,我收集的要求是真正得到访问者的浏览器,图像终于显示了时间

如果是这样的话,那么,还有可能获得技术pretty的快,这取决于信息应有的准确程度,而且如果你不介意通过XMLHTT prequest该图像 - 通过JavaScript的。如果是这样的话,你可以做整个服务器端的东西作为一个pre-必要,方法,另外,设置自定义响应头,即:

 标题(X-imageID',$ mysql_insert_id());
 

然后用readfile(blah.jpg');

在客户端,与XMLHTT prequest,在的onload设置事件的另一个请求到服务器,与图像ID与如 xhr.getResponseHeader(X-imageID')和当前时间(毫秒):新的Date()的getTime()

显然,你需要设置一些信息来区分的请求,这样服务器将只记录对图像的要求,并与更新时间的要求更新记录。

希望它帮助;)

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: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 ;)

这篇关于检查每个请求来apacheweb服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆