SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru Todd Temple's Avatar
    Join Date
    Mar 2005
    Location
    Tennessee
    Posts
    797
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can PHP Includes Slow Down My Page Loading Time?

    I have added two includes to load a header and footer via PHP and since I have added these includes the page loads incredibly slow. Is there an issue with page loading times when adding includes?

    Here is a link to the page I am referring to...
    LINK-
    http://www.flynnelectriccompany.com/test/


    Or is this a host issue?
    Todd Temple > T2 Design

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,191
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    Two includes themselves would not be a noticeable difference but the code within them may cause the issue. What is being done within each including – fetching remote content perhaps?
    The only code I hate more than my own is everyone else's.

  3. #3
    SitePoint Guru Todd Temple's Avatar
    Join Date
    Mar 2005
    Location
    Tennessee
    Posts
    797
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really fetching remote content... I don't guess. It is simply loading a menu or navigation for each.

    I am on the phone with the web hosting provider and they commented that I should not have absolute URLs in my include files and that I should change them to relative URLs. Would that help? That doesn't sound correct...
    Todd Temple > T2 Design

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    I hope you are not doing this: include 'http://domain.com/page...';
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Guru Todd Temple's Avatar
    Join Date
    Mar 2005
    Location
    Tennessee
    Posts
    797
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    I hope you are not doing this: include 'http://domain.com/page...';
    Why, yes I am. Is this bad news?
    Todd Temple > T2 Design

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    It is very bad. You are making PHP go out to the internet, it needs to connect to a DNS server to get the IP, then send out network request to establish a connection to the server, download the requested file...etc.

    Use file paths (like you do for files on your computer), not URLs to access files with PHP.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Guru Todd Temple's Avatar
    Join Date
    Mar 2005
    Location
    Tennessee
    Posts
    797
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by logic_earth View Post
    It is very bad. You are making PHP go out to the internet, it needs to connect to a DNS server to get the IP, then send out network request to establish a connection to the server, download the requested file...etc.

    Use file paths (like you do for files on your computer), not URLs to access files with PHP.
    Okay. Thanks for the info.
    Todd Temple > T2 Design

  8. #8
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Whoever thought allowing web URL's to be used with include and require should be shot.

  9. #9
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It also makes your code hard to move between local dev server and production one if all the absolute URLs are hard coded.

  10. #10
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Yeah, but honestly it was just an awesomely stupid idea, right up there with register globals and magic quotes. PHP is a good language, but damn if it doesn't have some terrible mistakes in its past.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •