Solved

Redirect users according to their bandwidth using Javascript

Posted on 2007-04-03
6
322 Views
Last Modified: 2013-11-25
Hi

Depending on the users bandwith I have to redirect the users to different asp pages
Is there a way to find if they are using high / low bandwith and redirect accordingly in Javascript ?

Thanks

0
Comment
Question by:ranirajesh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:ethoths
ID: 18841892
There is no precise way to do it but you could try this....

1) Create a page with some javascript i the head that gets the current time.
2) As the last line in the body get the time again. The difference between the two will be a measure of how long the page took to load (and hence the bandwith).
3) Depending on the time determined in 2 redirect to the appropriate page.

This will require a little calibration to get right and the page that you use to do this will have to have some amount of content to make it take some time to load but it should work.

(Another way would be to do the same thing in AJAX. Since this is asynchronous your users should not notice any delay.
0
 
LVL 11

Expert Comment

by:flipz
ID: 18842307
@ethoths - I don't believe your theory will work. Since Javascript is only processed once the code is already in the browser - calculating the time between to 'head' and 'footer' times is more a measure on how fast the client machine runs the script.

AJAX is a closer measure but again there are issues with server traffic etc. that would affect the response time and not sufficiently give you an accurate time. You could try it by taking the current time in JavaScript - place an AJAX call to an .asp page, take the time when the response is recieved - subtract the difference of the two times and subtract the processing time of the .ASP page and you will get a (somewhat inaccurate) measure of bandwith.

0
 
LVL 11

Expert Comment

by:ethoths
ID: 18842419
Yes you are right, the code will run as soon as it is in the browser. The code in the head will run just after the page starts loading and the footer code when it is loaded. It's not really measuring the time it takes the page to load, rather it's taking a measure of the time elapsed between the head code loading and the footer code loading. This is somewhat related to the time that the page takes to download.

My understanding was that the requirement was to determine whether the user has a low bandwidth connection (56k Modem) or a high bandwidth 2Mb ADSL. If this is the case then there is a factor of 40 between the them. In this case accuracy is not really required. If the page loads in less than 1 second then it's ADSL, if it takes more than say 20 then it's not. A bit of imperical calibration will yeild reliable results.

I agree that the AJAX approach will yeild even better results but it might be a little overkill for a simple "go/no-go gauge".
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Accepted Solution

by:
flipz earned 250 total points
ID: 18842459
ethoths - as I understand it - the actual JS code does not actually run until the page is fully loaded. Even if you put a timestamp in the head of the page - the JS call to get that time will not fire until the entire HTML is loaded into the browser. This means that any JS code running would have nothing to do with bandwith.

I agree that there is a considerable difference between dial-up and ADSL so some innacuracies are acceptable but what if a user on ADSL runs the page but the server is too busy to respond and takes 20 seconds to run? Then the client code would assume that the connection is dial-up.

In any case - ranirajesh - you're probably just better off the let the user choose their own connection speed.
0
 
LVL 11

Assisted Solution

by:ethoths
ethoths earned 250 total points
ID: 18842622
Yes flipz: you are correct about the running of the JS and my first suggestion would not run. My suggestion about AJAX looks like the best way.

Incidentally, the fact that a slow server or connection could result in tha inaccurate selection of page is a good thing. It does not really matter why the page is slow to load. If it is slow for any reason then the leaner version should be used.

Letting users choose has several disadvantages...

1) Some users won't know.
2) Some will choose the wrong answer
3) Some will be scared off by such a technical question.
4) It cannot dynamically auto configure
5) If the choice is perisited as a preference and the user then upgrades, they will not be getting the best experience.
0
 

Author Comment

by:ranirajesh
ID: 19353947
Thanks to both of you ... My mistake for not responding earlier ...  for the time being I have left the choice to the user , but in future I would definitely like to try out using AJAX
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question