• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4543
  • Last Modified:

PHP curl request is slow

Hi,

I'm using curl to retrieve sections of this page:
http://pastorlbm.com/index_03_newsevents.php

instead of the php include since it's by default disabled on networksolutions.

But it's so slow.

So I was reading on some posts that it could be a DNS issue. I found this script from here:
http://www.jeremyquinton.com/how-to-debug-slow-curl-requests-in-php/

and ran it and here is the output:

Array
(
    [url] => http://www.pastorlbm.com/
    [content_type] => text/html
    [http_code] => 200
    [header_size] => 284
    [request_size] => 56
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.03184
    [namelookup_time] => 0.003974
    [connect_time] => 0.005883
    [pretransfer_time] => 0.005965
    [size_upload] => 0
    [size_download] => 20988
    [speed_download] => 659170
    [speed_upload] => 0
    [download_content_length] => 20988
    [upload_content_length] => 0
    [starttransfer_time] => 0.030919
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [redirect_url] => 
)

Open in new window


So it seems the DNS namelookup doesn't seem to be the issue. What else could be causing this?

Thank you,
Victor
0
Victor Kimura
Asked:
Victor Kimura
  • 2
  • 2
3 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
It is a very slow page that takes about 14 seconds to load.  Part of that is caused by 5 "404 Not found" responses.  The initial page load is over 8 seconds before the browser can even start getting the rest of the files on the page.
0
 
Ray PaseurCommented:
With something like this you can often use Firefox YSlow to find many of the reasons a page is slow to load.  You will also need Firebug.

My page load time for http://www.pastorlbm.com/ was sub-second.

My page load time for http://pastorlbm.com/index_03_newsevents.php was painfully slow.  There are a lot of files showing in the HTML, as well as JavaScript calls to external web services.  And the queries for the calendar may be slow, too.

Also, there is the markup... sigh.
http://validator.w3.org/check?uri=http%3A%2F%2Fpastorlbm.com%2Fhome.html&charset=%28detect+automatically%29&doctype=Inline&group=0
0
 
Victor KimuraSEO, Web DeveloperAuthor Commented:
Ok, thanks, @Dave and @Ray. It's strange that the only real difference between those pages are the curl function calls which simply separate the page into sections. So all I'm doing is (instead of using PHP include) I'm using curl function calls to separate the left section, top, and footer sections so I can manage the code easier. But the resulting code I believe is all the same.

It's one of those terrible WYSIWYG from Network Solutions. It's temporary solution for now until I transition to something like Wordpress and some other hosted network provider that uses cPanel which I like.

I'll look at Yslow or G Pagespeed. I forgot to validate and I'm sure there are a lot of errors remaining. (sigh). I'll try and convince my pastor to switch but she said not right now I think. I'll try and clean up the code as best as possible and will report here.

Thank you, fellas!
0
 
Ray PaseurCommented:
PHP include() requires access to a disk drive, typically on the same server, so it's likely to be measured in the low milliseconds (7200 RPM means 8.3 ms per rotation, more or less).  In contrast, cURL means a trip to the internet, complete with domain name server lookups, socket connections, protocol handshakes, etc.  So it would be expected to be slower than include().  And a few cURL connections would be expected to be much slower that a few include()s.
0
 
Victor KimuraSEO, Web DeveloperAuthor Commented:
Ok, thanks, Ray! I didn't know that (the differences in performance between include() and curl()).

I read that include shouldn't be used because of security issues and it's better to use curl. I'm using curl right now because include is disabled by the hosting provider Network Solutions.

If I'm simply separating the content sections (i.e. header, footer, left sections) by using include() - that is, if I could use it by my hosting provider - then what would the security risk be and is there a way to mitigate or eliminate the security risk by using include (as opposed to curl)?

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now