Measuring Web Download Time (client Vs server side)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • duane

    Measuring Web Download Time (client Vs server side)

    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(AGA IN!!)
    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.
  • Janwillem Borleffs

    #2
    Re: Measuring Web Download Time (client Vs server side)


    "duane" <duawaktu@hotma il.com> schreef in bericht
    news:592d2609.0 309101047.33087 5cd@posting.goo gle.com...[color=blue]
    > 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 >
    >[/color]

    Try it the way the advertisement guys are doing it:

    <html>
    ....
    <script type="text/javascript">
    function isReady() {
    if ( document.cookie .indexOf('proce ssed') > -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



    Comment

    • duane

      #3
      Re: Measuring Web Download Time (client Vs server side)

      Thank you JWB =)

      It works like a charm!

      Comment

      Working...