Reputation: 333
I have a page that loads another page in it via cURL. Similar to this:
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo get_data($_GET["url"]);
How can I estimate the amount of traffic of each request ? Say, user wants to display imdb.com at my page, I want to know how much of my server's bandwidth was used at this request (including images and all css/js files that were passed).
Upvotes: 1
Views: 877
Reputation: 2581
Its kinda simple actually
curl_getinfo($ch, CURLINFO_SIZE_DOWNLOAD);
http://php.net/manual/en/function.curl-getinfo.php
Upvotes: 1