Page 1 of 1

Strange Refresh Problems - Duplicate Requests

Posted: Tue Jan 12, 2010 9:25 am
by Benwahballz
I am having a wierd issue with a php page that is refreshed. Ill explain as best I can.

I have Apache 2.2.14 with PHP 5.2.11 Running on a Windows 2000 Pro box.

(This problem exists on IE, I have another problem with firefox that i will explain after this)
When a page is viewed normally, by clicking a link, or directly typing in the address of the location in the address bar the page works fine. The problem happens when the page is refreshed (F5). The page loads, displays all the information, then is reloaded a second time before being "Done". I can prove that it is requested/loaded twice because I have a timestamp on the page that changes, as well as two requests in the apache access log. (see below)
Can anyone shed any sort of light to me on this? I find this really odd and have been banging my head on my desk for a good few hours researching and finding no results

Here is the code:

Code: Select all

 
<?php
echo "Time is: " . time() . "<br>";
$i = 0;
while ( $i < 2000000 )
{
    ++$i;
    $val = $i % 10000;
    if( $val == 0 )
    {
        echo " $i";
    }  
}
?>
 
And the results of the page after hitting refresh:
(This is first request)
Time is: 1263308975
10000 20000 30000 40000 50000 60000 70000 80000 90000 100000 110000 120000 130000 140000 150000 160000 170000 180000 190000 200000 210000 220000 230000 240000 250000 260000 270000 280000 290000 300000 310000 320000 330000 340000 350000 360000 370000 380000 390000 400000 410000 420000 430000 440000 450000 460000 470000 480000 490000 500000 510000 520000 530000 540000 550000 560000 570000 580000 590000 600000 610000 620000 630000 640000 650000 660000 670000 680000 690000 700000 710000 720000 730000 740000 750000 760000 770000 780000 790000 800000 810000 820000 830000 840000 850000 860000 870000 880000 890000 900000 910000 920000 930000 940000 950000 960000 970000 980000 990000 1000000 1010000 1020000 1030000 1040000 1050000 1060000 1070000 1080000 1090000 1100000 1110000 1120000 1130000 1140000 1150000 1160000 1170000 1180000 1190000 1200000 1210000 1220000 1230000 1240000 1250000 1260000 1270000 1280000 1290000 1300000 1310000 1320000 1330000 1340000 1350000 1360000 1370000 1380000 1390000 1400000 1410000 1420000 1430000 1440000 1450000 1460000 1470000 1480000 1490000 1500000 1510000 1520000 1530000 1540000 1550000 1560000 1570000 1580000 1590000 1600000 1610000 1620000 1630000 1640000 1650000 1660000 1670000 1680000 1690000 1700000 1710000 1720000 1730000 1740000 1750000 1760000 1770000 1780000 1790000 1800000 1810000 1820000 1830000 1840000 1850000 1860000 1870000 1880000 1890000 1900000 1910000 1920000 1930000 1940000 1950000 1960000 1970000 1980000 1990000 2000000

(This is second Request)
Time is: 1263308978
10000 20000 30000 40000 50000 60000 70000 80000 90000 100000 110000 120000 130000 140000 150000 160000 170000 180000 190000 200000 210000 220000 230000 240000 250000 260000 270000 280000 290000 300000 310000 320000 330000 340000 350000 360000 370000 380000 390000 400000 410000 420000 430000 440000 450000 460000 470000 480000 490000 500000 510000 520000 530000 540000 550000 560000 570000 580000 590000 600000 610000 620000 630000 640000 650000 660000 670000 680000 690000 700000 710000 720000 730000 740000 750000 760000 770000 780000 790000 800000 810000 820000 830000 840000 850000 860000 870000 880000 890000 900000 910000 920000 930000 940000 950000 960000 970000 980000 990000 1000000 1010000 1020000 1030000 1040000 1050000 1060000 1070000 1080000 1090000 1100000 1110000 1120000 1130000 1140000 1150000 1160000 1170000 1180000 1190000 1200000 1210000 1220000 1230000 1240000 1250000 1260000 1270000 1280000 1290000 1300000 1310000 1320000 1330000 1340000 1350000 1360000 1370000 1380000 1390000 1400000 1410000 1420000 1430000 1440000 1450000 1460000 1470000 1480000 1490000 1500000 1510000 1520000 1530000 1540000 1550000 1560000 1570000 1580000 1590000 1600000 1610000 1620000 1630000 1640000 1650000 1660000 1670000 1680000 1690000 1700000 1710000 1720000 1730000 1740000 1750000 1760000 1770000 1780000 1790000 1800000 1810000 1820000 1830000 1840000 1850000 1860000 1870000 1880000 1890000 1900000 1910000 1920000 1930000 1940000 1950000 1960000 1970000 1980000 1990000 2000000



Notice the different in the timesamp at the top. (also, these arent displayed consecutively down the screen, the first set was displayed which I copied to clipboard, then the page seemed to magically "refresh" again and I copied the second results to the clipboard)
Also, here is the access log from apache:

192.168.100.25 - - [12/Jan/2010:09:09:35 -0600] "GET /qad/qad5.php HTTP/1.1" 200 1590
192.168.100.25 - - [12/Jan/2010:09:09:38 -0600] "GET /qad/qad5.php HTTP/1.1" 200 1590

You can see obviously that the script ran twice, 3 seconds apart.

The other strange thing is, if I do this in firefox it works fine (loads and is requested only once). The one problem I found with firefox though, is if I increase the loop to something like 5000000, and only display the value of $i each loop, it only gets to between 500k 1.3Million loops and just stops. Is this because of a setting in firefox? If I run this in IE it seems to get right to the end (with the duplicate request on a refresh) and it also seems to run MUCH faster.

Any help at all will be greatly appreciated.

:banghead: :banghead:

Re: Strange Refresh Problems - Duplicate Requests

Posted: Tue Jan 12, 2010 9:57 am
by SidewinderX
Not sure about the two requests, but Firefox is set to timeout after 300 seconds.

Re: Strange Refresh Problems - Duplicate Requests

Posted: Tue Jan 12, 2010 9:59 am
by Benwahballz
Strange thing is, the script doesnt stop running after 5 minutes. It is more like 2 minutes, MAYBE 3 at max. It varies.

Re: Strange Refresh Problems - Duplicate Requests

Posted: Wed Jan 13, 2010 8:19 am
by Benwahballz
I havent tried anything new with this, I sort of moved on and just hope that none of my scripts run into this problem when they move to production.

Again, if anyone else has tested this, or tried it let me know if you get the same results or not. It would be nice to know if it is a browser setting, or apache, or php.....still stumped