My bandwidth speed tester, is there a better way?

Discussion in 'HTML' started by Guy, Dec 4, 2003.

  1. Guy

    Guy Guest

    I'm trying to make a web page for my server that will test my download speed
    to it.

    What I've done is pretty basic but has a drawback.

    1. I click a button
    2. It records the start time
    3. It loads an image
    4. The image onload event triggers when it's all loaded
    5. It gets the end time
    6. It calculates the speed

    The images are approx 1.5 MBytes.
    It works, but if I try it a second time, the image is already loaded in
    cache and so it doesn't work.
    So then I thought (not hard enough obviously) of alternating between 2
    images.
    So it works twice but then both images are in cache so I again have to
    delete my temp Internet files.
    I even tried to use META tags to prevent caching but I never understood how
    these work and they don't work here!?
    Is there a better way of doing this.

    G.Doucet
    PS. Here is my code.

    <HTML>
    <HEAD>
    <META Http-Equiv="Cache-Control" Content="no-cache">
    <META Http-Equiv="Cache-Control" Content="max-age=0">
    <META Http-Equiv="Pragma" Content="no-cache">
    <META Http-Equiv="Expires" Content="0">

    <SCRIPT language=javascript>

    var a;
    var b;
    var c;
    var d;
    var e;
    var h;
    var m;
    var s;
    var n;

    n=0;

    function gettime()
    {
    var t = new Date();
    h = t.getHours();
    m = t.getMinutes();
    s = t.getSeconds();
    }
    function begin()
    {
    self.document.f1.i5.value='Testing...';
    gettime();
    a=s;
    self.document.f1.i1.value=h + ":" + m + ":" + s;
    self.document.f1.i2.value='';
    if(n==0){n=1;self.document.pic.src='e1.gif';}
    else{n=0;self.document.pic.src='e2.gif';}
    }
    function calc()
    {
    gettime();
    b=s;
    self.document.f1.i2.value=h + ":" + m + ":" + s;
    if((b-a)<0){b=b+60;}
    c=(b-a);
    if(c<2)
    {
    d="";
    e="";
    self.document.f1.i5.value='You must delete your temporary Internet
    Files';
    }
    else
    {
    d=Math.round(15994310/(c*1024))/10;
    e=Math.round(15994310/c)/10;
    self.document.f1.i5.value='Done!';
    }
    self.document.f1.i3.value=d;
    self.document.f1.i4.value=e;
    }
    </SCRIPT>
    </HEAD>

    <BODY>
    <CENTER>


    <FORM name=f1>
    <TABLE border=1><TR><TD align=center>
    <BR>
    <FONT SIZE=4>Trial Speed-Test site</FONT><BR><BR>
    <TABLE cellspacing=0 cellpadding=2 border=0>
    <TR><TD>Start time </TD><TD><INPUT name='i1' value=''>
    </TD></TR>
    <TR><TD>End Time </TD><TD><INPUT name='i2' value=''>
    </TD></TR>
    <TR><TD>Speed </TD><TD><INPUT name='i3' value=''> kilobytes per second
    </TD></TR>
    <TR><TD> </TD><TD><INPUT name='i4' value=''> Bytes per second
    </TD></TR>
    </TABLE>
    <BR>
    <IMG name='test' width=100 height=100 border=1 src='test.gif'
    onclick='self.begin();'>
    <BR><BR>
    <INPUT name='i5' value='' size=50>
    <IMG name='pic' width=0 height=0 border=0 src='' onload='self.calc();'>
    </TD></TR></TABLE>
    </FORM>

    </CENTER>
    </BODY>
    </HTML>
     
    Guy, Dec 4, 2003
    #1
    1. Advertising

  2. Guy

    brucie Guest

    in post <news:URyzb.4293$>
    Guy said:

    > What I've done is pretty basic but has a drawback.
    >
    > 1. I click a button
    > 2. It records the start time
    > 3. It loads an image
    > 4. The image onload event triggers when it's all loaded
    > 5. It gets the end time
    > 6. It calculates the speed
    >
    > The images are approx 1.5 MBytes.
    > It works, but if I try it a second time, the image is already loaded in
    > cache and so it doesn't work.


    use a bit of server side scripting to rename the image file every time
    its used so no matter how many times the test is run the browser will
    receive an image with a different name. easy peasy.

    > I even tried to use META tags to prevent caching


    <meta> cache directives are not effective, they're just so newbies can
    feel like they're in control when they're not. (for some reason newbies
    are always control freaks)

    you configure the server to specify cache directives but once anything
    has left your server you have no control over it. cache directives can
    be and are ignored all the time.

    --
    brucie
    04/December/2003 03:04:54 pm kilo
     
    brucie, Dec 4, 2003
    #2
    1. Advertising

  3. Guy

    Sid Ismail Guest

    Sid Ismail, Dec 4, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QW5kcmV3IEhheWVz?=

    C#/Java Souce Code For ASP.NET Bandwidth/Speed Test Page Needed

    =?Utf-8?B?QW5kcmV3IEhheWVz?=, Mar 5, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    2,000
    =?Utf-8?B?QW5kcmV3IEhheWVz?=
    Mar 7, 2007
  2. Replies:
    2
    Views:
    345
    Gabriel Genellina
    Nov 15, 2007
  3. Paul Rubin
    Replies:
    5
    Views:
    440
    Hendrik van Rooyen
    Aug 6, 2009
  4. Market Mutant

    Is there a Mod_Perl Script Tester?

    Market Mutant, Jan 17, 2004, in forum: Perl Misc
    Replies:
    8
    Views:
    121
    Michele Dondi
    Jan 20, 2004
  5. me2
    Replies:
    39
    Views:
    1,740
    Arne Vajhøj
    Jan 12, 2013
Loading...

Share This Page