Init.php and a Question of Speed

11 posts by 6 authors in: Forums > CMS Builder
Last Post: June 4, 2010   (RSS)

By Perchpole - May 30, 2010

Hello, All -

It seems like I've been using CMSB for years. During that time I've become familiar with its many great features and learned - I hope - to take advantage of most of them.

The result is that my CMSB sites are becoming ever more complex. The only downside is that with such complexity comes repetition!

My goal in recent weeks has been to see if I can cram as much CMSB content into as few pages as possible. (With careful planning you can deliver a fairly complex CMSB website through just one page.) One of the ways I've sought to do this is by using an init.php file. Instead of adding variants of the same code to the <head> of each page, I simply put all of the data into one file (the init.php) and call it via a php include.

In effect you're adding the same code to every page - but you only ever need to create it once. Better still, as the site expands you just keep updating the init.php.

From a design viewpoint it seems to work flawlessly. My only concern is I do not know how much of a hit the server is taking every time a new page is loaded.

Obviously there must come a point where the presence of so much data will start to have an adverse effect. I have no idea how to calculate this so wondered if the PHP aficionados amongst the community would provide some information and suggestions.

As an example, the init.php file that I'm currently working with is about 7kb. It includes approximately 10 list() functions along with numerous other snippets of code.

:0)

Perchpole

Re: [Perchpole] Init.php and a Question of Speed

By aev - May 31, 2010

We use the same method you describe here. We haven't noticed any performance problems on the sites we build, but they all have less than 100 pages each.

-aev-

Re: [Perchpole] Init.php and a Question of Speed

By Donna - May 31, 2010

Hey Perch!

Nope, no problem doing that at all -- in fact, we often setup something exactly like that in the sites we create -- our listing/realty/auto templates all use a separate init file just to simplify things a bit. :)
Donna

--
support@interactivetools.com

Re: [Donna] Init.php and a Question of Speed

By Perchpole - May 31, 2010

Hi, Folks -

Thanks for your response. From what you tell me it seems I can breath a little easier!

However, in terms of the wider debate, and best practise, I assume there are certain things we should bear in mind to avoid putting uneccesary strain on a server.

For example, I've heard that too many foreach loops can make things slow down considerably.

:o/

Perch

Re: [Perchpole] Init.php and a Question of Speed

By Jason - June 2, 2010

Hi Perch,

Yes, foreach loops can slow down the server, but you probably wouldn't notice any change in performance unless you are looping through quite a large number of records. .

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Perchpole] Init.php and a Question of Speed

By Djulia - June 3, 2010

Hi,

I use sometimes this site to obtain information :
http://www.phpbench.com/

Djulia

Re: [Perchpole] Init.php and a Question of Speed

By Djulia - June 3, 2010

Hi,

You can cache [font "Verdana"]foreach loops in files on your server.

Djulia

Re: [Djulia] Init.php and a Question of Speed

By Perchpole - June 3, 2010

Sounds good.

Plz tell me more!

:0)

Perch

Re: [Perchpole] Init.php and a Question of Speed

By Djulia - June 3, 2010

I use this class:
http://codecanyon.net/item/caching-class/69006

That should help you!

Djulia