0

A very odd glitch I've encountered recently. I run Chrome Version 98.0.4758.81 (Official Build) (64-bit) (first noticed issue on v.97). When I run my PHP script for the first time by entering URL - it runs 1 time. When I press RELOAD button - it runs one time too. But when I put cursor to Adress bar with needed URL already there and press ENTER - script runs 2 times. Disabling pages prefetching does not help. No session_start(), html etc. Pure php script that works with BD and executes in 12-15 seconds (each run). Edge works fine - when I RELOAD or press ENTER.

So, here is the code that runs 2 times, when I press ENTER in adress BAR

<?php
include_once('/home/alex/public_html/dev/config.inc.php'); // just varibles
$conni = mysqli_connect("", $db_user, $db_pass, $db_name);
mysqli_query($conni,"SET NAMES 'utf8'");
mysqli_query($conni,"SET CHARACTER_SET 'utf8_unicode_ci'");
mysqli_query($conni,"INSERT INTO tmp (`tm`,`user`) VALUES ('2','".date ("Y-m-d H:i:s")."');");
sleep (10);
?>

And here is result in PHPMyadmin

Sanan Ali
  • 2,349
  • 1
  • 24
  • 34
dMole
  • 89
  • 1
  • 9
  • 1
    I have never experienced this as a Chrome user. I suspect something different, like a redirect without the script halting. That happens when you don't put `exit;` after `header('Location: ...');` for example. – Daniel W. Feb 02 '22 at 13:30
  • could be this https://stackoverflow.com/questions/2009092/page-loads-twice-in-google-chrome ? – Marcel Preda Feb 02 '22 at 13:32
  • 1
    Good scenario in that QA. It's not a Chrome issue but something with your routes/redirects/isolation of processing – Daniel W. Feb 02 '22 at 13:34
  • @Marcel Preda. Nope. Absolutely not. – dMole Feb 02 '22 at 13:59
  • @Daniel W. Good guess. But it doesn't explain working Reload, first run and no such glitch in Edge – dMole Feb 02 '22 at 14:00
  • 2
    @dMole any plugins in chrome? What happens when you look at the tools( F12). You can persist the logs there - might be 2 records? Also what happens when you just have a vanilla php page, i.e just try and do an echo and then a die() after that mysqli_query – Richard Housham Feb 02 '22 at 14:08
  • You can also check it from Incognito tab – Alon Eitan Feb 02 '22 at 14:10
  • @Richard Housham. Removing Sleep(10) makes only 1 record in DB. What I found out using F12 - page runs 2 times - first one is 301 redirect on self. Second one - 200 - ok. – dMole Feb 02 '22 at 14:23
  • 301 = moved perminantly - is there any header code afterwards somewhere? – Richard Housham Feb 02 '22 at 14:39
  • Nope. Just 301 - Moved Permanently. And runs again same page with 200 - ok. I made a request to hoster. Hope he will give some explanation. – dMole Feb 02 '22 at 14:48
  • That's definitely your server and not Chrome. The difference between browsers is the caching. "Moved Permanently" offen gets cached in browsers. Then there is a difference between hard-reload and soft-reload. What URL the redirects point to? – Daniel W. Feb 02 '22 at 15:08
  • https://www.mmcs.com.ua/dev/tmp.php After link opens - try to press ENTER in adress bar – dMole Feb 02 '22 at 16:44

0 Answers0