测量客户端在浏览器中启动请求到服务器获取请求之间的时间
有没有办法衡量这个?
当然,对于 get 请求,客户端不会一致发送可用的标头。
我的一个想法是从查询字符串中获取它,但这可能吗?类似于(伪代码如下)
http://server/default.aspx?t=(new Date().getTime())
另一种可行的方法是让用户点击一个非常小的页面,该页面附加如上所述的查询字符串,但希望尽可能避免重定向。
(总体目标是收集每个请求的此类统计信息。在某些假设下,服务器处理时间和服务器到客户端更可行。)
提前致谢。
Is there a way to measure this?
Certainly, for get requests, no available headers are being sent consistently from clients.
One idea I got is to get that from query string, but is that possible? Something like (pseudo-code follows)
http://server/default.aspx?t=(new Date().getTime())
Another one that would work is to have users hit a very small page that appends a query string as above, but wanted to avoid a redirection if possible.
(Overall goal is to gather per-request such statistics. The server processing time and server to client are more doable, under some assumptions.)
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在初始页面加载后通过 AJAX 请求来完成此操作,您可以从一开始就控制请求。在查询字符串中传递 UNIX 时间,然后当它到达服务器时取差值。我对 iis7 不熟悉,所以你必须确保考虑到时区。这个数字可能非常不稳定,因为它基本上只是计算延迟和 DNS 查找,这对于每个客户端来说都是不同的。
I've done this through an AJAX request after the initial page load where you have control over the request from the very beginning. Pass the UNIX time in the query string and then when it reaches the server take the difference. I'm not familiar with iis7 so you'd have to make sure that timezone's are accounted for. This number could be very erratic since it's basically just calculating latency and DNS lookups which is different for every client.
请求是否从您可以控制的初始页面开始?在这种情况下,您可以通过初始响应发送服务器时间,然后当用户位于页面上时使用 JavaScript 代码逐秒增加该时间。这样,您就可以在页面上拥有服务器同步时间,并且当从该页面发送请求时,您可以将同步时间与该请求一起发送,然后您所需要的就是计算服务器上的差异。
Does the request start from an initial page that you have control over it ? in that case you can send the server time with the initial response, and then increment that time second-by-second with a javascript code while the user is on the page. this way you can have a server-synchronized time on the page and when a request goes to be sent from that page you can send that synced time with that request, then all you need is calculate difference on the server.