Nicolas Bouvrette
Nicolas Bouvrette

Reputation: 4767

PHP Curl/file_get_contents inconsistent response time in Chrome

I'm on Windows 7 (using a VirtualBox VM) to do some development. I have PHP/5.5.13, Apache 2.4.9, Chrome 35.0.1916.153. I'm seeing some very inconsistent behavior when I run the following code :

index2.php

<?php
echo "Load time before 'file_get_contents': ".(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])."<br/>\r\n";
echo file_get_contents('http://custom.local/index3.php');
echo "Load time after 'file_get_contents': ".(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])."<br/>\r\n";
exit;
?>

index3.php

<?php
echo "Load time inside 'index3.php': ".(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])."<br/>\r\n";
exit;
?>

Here is the results in Chrome (I get consistent response time between 8 and 28 seconds after curl_exec). Response time fluctuates a lot as well:

Load time before 'file_get_contents': 0.002000093460083
Load time inside 'index3.php': 0.0026569366455078
Load time after 'file_get_contents': 15.411452054977

Upvotes: 0

Views: 554

Answers (1)

Nicolas Bouvrette
Nicolas Bouvrette

Reputation: 4767

It seems that after all it was an Apache issue.

Chrome's advanced options "Predict network actions to improve page load performance" would use more threads than provisioned by the default Apache config (Windows 2.4.9 Windows build).

The fix is simple in httpd.conf :

AcceptFilter http none

More details here:

http://www.apachelounge.com/viewtopic.php?p=28142#28142

Upvotes: 1

Related Questions