php - i'm doing a script but i have an issue with page loading -


i'm doing website(in php) shows if game server online or offline.
i've managed figure out , got work.
problem if multiple servers offline, website takes 10-20 seconds load.

loads instantly if servers online.

is there way can make website load instantly if servers offline?

this main function.(the rest ip's , server names.)

function pingdomain($domain){      global $sport, $lport, $port, $l1, $l2;      if ($domain == $l1){         $port = $lport;     }     else if ($domain == $l2){         $port = $lport;     }     else{         $port = $sport;     }      $starttime = microtime(true);     $file      = @fsockopen($domain, $port, $errno, $errstr, 1);     $stoptime  = microtime(true);     $status    = 0;      if (!$file) $status = -1;  // site down     else {         fclose($file);         $status = ($stoptime - $starttime) * 1000;         $status = floor($status);     }     return $status; } 

make cron job in server , run code every 1 minute, save result in database. live web site can load servers status database quickly, use ajax avoid page refreshing.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -