Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:02:59+00:00 2026-06-04T15:02:59+00:00

The code works, but it takes up to 10 seconds to load the page.

  • 0

The code works, but it takes up to 10 seconds to load the page. Then I add curl_getinfo(), and discovered the redirect time has used 90% of the total time….

<?php
//
$url = "http://www.somesite.com/###";

$username = 'username';
$password = 'password';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);

$out = curl_exec($ch);

print "error:" . curl_error($ch) . "<br />";
print "output:" . $out . "<br /><br />";

$info = curl_getinfo($ch);
print_r($info);

curl_close($ch);

?>

curl_getinfo() shows:

Array ( 
[url] => http://www.somesite.com/xxx
[content_type] => text/xml;charset=UTF-8 
[http_code] => 200 
[header_size] => 2760 
[request_size] => 5576 
[filetime] => -1 
[ssl_verify_result] => 0 
[redirect_count] => 3 
[total_time] => 10.751595 
[namelookup_time] => 2.0E-5 
[connect_time] => 0.001612 
[pretransfer_time] => 0.001613 
[size_upload] => 0 
[size_download] => 24506 
[speed_download] => 2279 
[speed_upload] => 0 
[download_content_length] => 24506 
[upload_content_length] => 0 
[starttransfer_time] => 0.62479 
[redirect_time] => 9.080637 <--------------
[certinfo] => Array ( ) 
[redirect_url] => 
) 

See [redirect_time] => 9.080637 ?

It takes up 90% of the total time.

How to improve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:03:00+00:00Added an answer on June 4, 2026 at 3:03 pm

    CURLINFO_REDIRECT_TIME
    Pass a pointer to a double to receive the total time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started. CURLINFO_REDIRECT_TIME contains the complete execution time for multiple redirections. (Added in 7.9.7)

    I say the most likely is the transfer fase: your ‘ http://www.somesite.com/xxx‘ just being terribly slow (which is hard to fix if it isn’t your site), 3 redirects taking > 3s each. But you could check how fast the dns lookup & connects are, seem ok though in that data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the code below works fine but it takes an absolute age to run. How
I have a ASP.NET program that works just fine but takes 10 seconds to
Currently my code below works fine but it's a bit of overkill. In my
The following code works in Firefox but in Internet Explorer it returns error Object
This code works for windows 7 but doesn't work for windows XP (outputs only
The following code works with Visual Studio 2008 but not with GCC/G++ 4.3.4 20090804.
This code works great for generating thumbnails, but when given a very large (100MB+)
The following (absurd but illustrative) code works as expected by mutating the list defined
The following code works on my laptop but doesn't work on remote server: <?php
The following code works fine in most browsers but it won't work in Internet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.