0

I have a code that echo's whatever I have on my database. It works normally when using WiFi, but when I use cellular network on any phone or if I hotspot to my computer, it takes about 2 hours to echo the new information (Even if I refresh the page it does not change until after 2 hours or so).

Note: - I live in Egypt - I'm using Vodafone, and my friends use Etisalat (cell companies) and neither works properly. - I'm using Alwaysdata to host my mysql database

Note 2: - My brother lives in Italy and I asked him to check the site and refresh (using his cellular network) when I update the data in the database and it works perfectly for him.

What can I do so that it works here in Egypt because here is where the app I'm making is supposed to work

Update: This is my code trying to stop using cache

<?php
$server_name = "**********";
$server_username = "**********";
$server_password = "**********";
$dbName = "**********";

//$username = $_POST["usernamePost"];
//$password = $_POST["passwordPost"];

//Make the connection_aborted
$conn = new mysqli($server_name, $server_username, $server_password, $dbName);

//Check connection_aborted
if (!$conn)
{
    die("Connection Failed. ". mysqli_connect_error());
}
else 
{
    //echo("Connection Success" . "<br>");
}

/*header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");*/

$sql = "SELECT id, gateName, Toggle FROM parking";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0)
{
    //show data for each row
    while ($row = mysqli_fetch_assoc($result))
    {
        echo "ID:" . $row['id'] . "|Gate Name:" . $row['gateName'] . "|Toggle:" . $row['Toggle'] . ";";
    }
}

?>

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • I have no idea what this has to do with programming. – Funk Forty Niner Feb 20 '18 at 19:41
  • @FunkFortyNiner I made the whole thing work using programming... I just need to figure out how to fix that one issue – Nor Alexanian Feb 20 '18 at 20:30
  • What is size of data? Is using any cache? You serve response with right **no cache** headers? Do you run any network speed test? (find test server near your hosting server) – bato3 Feb 20 '18 at 20:55
  • @bato3 My Wifi Speed is: Ping 28ms, Download 4.63 mbps, Upload 0.88 | My Cellular Network Speed is: Ping, 115ms, Download 1.04 mbps, Upload 0.58 mbps. =================== The data I'm transferring is just varchar with 20 characters maximum – Nor Alexanian Feb 20 '18 at 21:24
  • Probably your cellular network caches the results. Do you send right cache control headers? https://stackoverflow.com/a/4485194/1194525 or use other techniques to get fresh version, eg: fake version: `?v=random_text-number_etc` – bato3 Feb 20 '18 at 21:33
  • @bato3 I don't use those, I've actually never heard of it, but I'll try to implement it in my code and I'll let you know if it works – Nor Alexanian Feb 20 '18 at 22:07
  • @bato3 I added my php code in the question, where should I put the header and which one should I use? I am really new to this – Nor Alexanian Feb 20 '18 at 22:23
  • Your place is good, but safer is begin of file. and change filename BTW: Do you display this file by POST method? This shouldn't be cached by any proxy. – bato3 Feb 20 '18 at 22:28
  • 1
    @bato3 It worked! Thank you so much! I was stuck on this problem for more than a week now. - And no I don't use the post method – Nor Alexanian Feb 20 '18 at 22:44

0 Answers0