Jon
Jon

Reputation: 6541

multiple php calls slowing page load?

I am rewriting a HTML site into PHP. There are various changing menus I want to make php calls:

 <?php include("header.php");?>

With the footer, and sidebars I have 4 or 5 php includes on each page.

How much am I slowing the pageload with 5 php calls? If I want a fast load is it worth sacrificing sitewide editabitity and calling less php pages? Or its only a few milliseconds?

Is there any difference speed wise between calling 2 css files or 2 php files?

( What is a good caching system to use for such simple php calls? )

Upvotes: 0

Views: 143

Answers (4)

user1329212
user1329212

Reputation:

For static files, like css files, merging them will decrease page loading time. Because these files are not server-side files.

Clients send more than one request for downloading these files. It will effect loading time. But php files are server-side files.

It won't effect loading time too much (if the files are not complicated too much).

Upvotes: 1

AD7six
AD7six

Reputation: 66208

including files costs ~nothing

The act of including a file in php is negligible, less than 1ms. Splitting a file into several chunks and including the component files will have no noticeable difference in performance compared to including one file with the equivalent markup/php logic in it.

static files are always faster than php

Serving a css file with a webserver (apache) will always be faster and more efficient than making a request to a php file - as a webserver can handle serving static files (and appropriate headers) without involving php at all. In simplistic terms: Less processes/logic means faster performance.

Upvotes: 1

Mohammad Areeb Siddiqui
Mohammad Areeb Siddiqui

Reputation: 10179

As said by @Jordan Denison it a server-side include and so should not take much time. One thing more, If you will include your page from an another domain then it will cause performance issues because then PHP has to go out to the internet connect to DNS and that all stuff but if it is on the same domain or in the same root then it should not take much time.

Upvotes: 0

Jordan Denison
Jordan Denison

Reputation: 2727

That is a server-side include and the browser doesn't have to make a separate request for it, so it should be only a few milliseconds to process each include.

Upvotes: 1

Related Questions