limboy
limboy

Reputation: 4089

how to get the server's execution time via curl

for example, I request www.domain.com via curl in php

$curl = curl_init('http://www.domain.com');
curl_exec($curl);

var_dump(curl_getinfo($curl));

I can get 'total_time', 'starttransfer_time', 'connect_time',etc. but I just can't get the server's execution time (sometime, this curl request takes a lot time, but most is wasted in transfer). is it possible or I missed some parameters?

Upvotes: 0

Views: 2222

Answers (1)

Sander Marechal
Sander Marechal

Reputation: 23216

That's not possible. There is no way for cUrl to know how much time was spend by the server processing your request, and how much was lost due to transfer.

If you really need this information you could try including it on the page you are requesting through cUrl and parsing it out. For example, add a little message to the footer of the page that says something like page generated in xx.yyyy seconds. Or even cleaner, add a custom HTTP header that contains the execution time. Then read that header on the cUrl side.

Upvotes: 1

Related Questions