Hi All,
I need to get the download speed of the user visiting my site, Is it possible with PHP? If so, How to do that?.
Please advice..
Thanks in advance.
Hi All,
I need to get the download speed of the user visiting my site, Is it possible with PHP? If so, How to do that?.
Please advice..
Thanks in advance.
Not sure how you would do that in PHP (running at the wrong end, on the server not the client), but I imagine you could get an idea of the download speed using AJAX.
You might have some piece of JavaScript asynchronously call back to your website at some fixed point during the page load to give you an idea of how long it took for the client to receive the page to that point.
Alternatively, you could have some JavaScript execute a file download from your site and time the download, calling back with the time when the download was complete. This way would probably be a more reliable indication as the callbacks are not part of the download time computation.
Updated for comment
A network connection to the local machine, using for example 'localhost' as the destination address will not actually hit the network.
You can verify this with a simple ICMP ping.
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.041 ms
Check out the times - 0.045ms is very small.
However, if you talk to a remote host even if it's pretty much as close as it can be, because you're actually interacting with the network everything slows down.
PING 192.168.xxx.xxx (192.168.xxx.xxx) 56(84) bytes of data.
64 bytes from 192.168.11.1: icmp_seq=1 ttl=64 time=1.85 ms
64 bytes from 192.168.11.1: icmp_seq=2 ttl=64 time=1.54 ms
In this example it's about 40x faster on the localhost connection, but I've known it be much more - so you would expect significantly slower performance talking to a remote host than the local host.
Hope that helps explain.
There is only one good way, which is to ask the user. Try to give meaningful names, so you don't confuse the computer-illiterate too much.
The only other option is to send something sizable to the the user and time how long it takes to arrive, but wasting other peoples bandwidth is rude, particularly if you end up clogging a connection they share with someone.