A terribly long response from the file_get_contents function. I am running the following code

 $postdata = http_build_query(array( 'ip' => '' . $_SERVER['REMOTE_ADDR'] . '' )); $opts = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $t = microtime(true); $result = file_get_contents($this->engine_domain . 'GeoIP/get_geo.php', false, $context); 

I used to receive an answer in an instant, but now I wait 15 seconds. What could be the problem?

  • And what does traceroute say from the host on which this script runs to the host on which the service is located? - chernomyrdin
  • It seems that this is not about php, but about server settings, since on other sites this code is quickly executed. - qpl
  • Maybe on the other side of the service there are some restrictions on your IP due to frequent use? - chernomyrdin

2 answers 2

Maybe it would be easier to use a local GeoIP database?

    If there are requests for other domains, then it is exactly in them. Perhaps they changed their address there, or what about the Internet?