简体   繁体   中英

PHP or javascript to verify a broadband connection (client Side)

Is there a way to use a PHP script in a website to verify that a given visitor has a broadband connection (some minimum downstream kbs ) before proceding to render certain or all elements of a webpage?

Let's see...

When the client requests page #1, store the timestamp in the session. Add some JavaScript to page #1, so that the client would start downloading a large file (say, 5MB) as soon as the page is loaded, and then request page #2 as soon as the download has completed. It should be all AJAX, so that everything happens in the background.

Now, page #2 compares the current timestamp with the original timestamp stored in the session. The difference would tell you roughly how long it took for the client to download the large file. If you're satisfied with the speed, you send more page elements via AJAX again.

But this is a bad idea.

Not only does this method require transferring an unnecessary file (which can cost extra money for mobile clients), but it's also extremely unreliable. Latency (think "ping") between the client and the server, CPU usage on the client side, congestion on the wire, and myriad other factors will affect the download time. You might as well just send the real content in the time it takes to run the speed test.

In conclusion, there's no way to do it. Just render a reasonably sized version of the page, and load large elements (such as videos) only after the client clicks something. If anybody is still on dial-up, hopefully they'll know not to click on videos.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM