My bandwidth speed tester, is there a better way?

G

Guy

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>
 
B

brucie

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top