Measuring Web Download Time (client Vs server side)

D

duane

Dear Experts:

I am trying to measure a HTML page download time on the client side
and store the value into a textfile located in the server.

I have successfully measured the page download time (client-side)
using JAVASCRIPT and write this value into a textfile in the server
using PHP script. No problem so far.

I call my PHP script using JAVASCRIPT (myPage.HTML):

<BODY ONLOAD = if (first time entering this page) MyPHPScript >

where

MyPHPScript: PHP script that writes values on the server

The problem is after the value is written to the textfile
(server-side), I want the program to go back displaying the HTML page
and finishes where it left off. However with the way I do it, I keep
getting infinite loop. This is the reason:

1. in myPage.HTML => 1st time it reaches BODY ONLOAD -> it'll call
MyPHPscript
2. in MyPHPScript => I redirect the page back to myPage.HTML
3. in myPage.HTML => 2nd time it reaches BODY ONLOAD -> it'll call
MyPHPscript(AGAIN!!)
4. Back to step #2, then to step #3....(infinite loop)

My goal is to prevent the client from knowing that I am calling
MyPHPScript in between my HTML pages. I have about 50 HTML pages right
now that are already running very well and would like to measure the
download time for each page on the client side. I try to minimize my
interference with the original flow of the existing system.

Your help would be greatly appreciated.
 
J

Janwillem Borleffs

duane said:
Dear Experts:

I am trying to measure a HTML page download time on the client side
and store the value into a textfile located in the server.

I have successfully measured the page download time (client-side)
using JAVASCRIPT and write this value into a textfile in the server
using PHP script. No problem so far.

I call my PHP script using JAVASCRIPT (myPage.HTML):

<BODY ONLOAD = if (first time entering this page) MyPHPScript >

Try it the way the advertisement guys are doing it:

<html>
....
<script type="text/javascript">
function isReady() {
if ( document.cookie.indexOf('processed') > -1 ) {
// Avoid caching by appending a random number to the URL
random = new Date().valueOf();
document.images['readygif'].src = 'thephpfile.php?' +
random;
// Create a cookie to remember that this page has been
visited
document.cookie = "processed=1";
}
</script>
....
<body onload="isReady()">
...
<img src="dot.gif" name="readygif" height="1" width="1" />
</body>
</html>


Then, thephpfile.php would contain something like this:

<?
// Mark whatever information you need

header("Content-Type: image/gif");
// include a basic gif image that you have prepared
// or generate one using the GD functions
?>


HTH,
JW
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top