Checking someones bandwidth and loading content based on it

后端 未结 6 1626
忘掉有多难
忘掉有多难 2021-02-14 21:29

I have seen a number of questions that don\'t answer this, is it possible to check someones bandwidth using java script and load specific content based on it?

The BBC se

6条回答
  •  野的像风
    2021-02-14 22:05

    Well, like I said in my comments, you can choose 2 approaches:

    1) You are in the context of a mobile app, then you can query the technology used by the device directly so you can notify the server directly what type (and size) of content you area able to render. I think phone gap can help you with accessing some of the native mobile API's using JavaScript.

    2) The server-timer thing. You can "serve" some files yourself, lets say you have a magic file in your landing page, that, as soon as the client request the file, you grab this HTTP request with a custom handler. You "manually" serve the file by writing to the output stream, and you measure the bytes send and the time it took to reach the EOF, then you can somehow measure the bandwith. Combine this with the session cookie and you have this information per connected browser.

提交回复
热议问题