Behind the PHP curtain

Hello,

I’m about to beta test my first web site, the majority of which has dynamic, PHP components. It’s been my first foray into PHP and I’ve come to really enjoy writing in the language. Now that my site is ready to go, I’ve begun to hear about and think about optimizing it; I use CloudFlare, for example, to cache javascript and css.

I wrote a post recently asking about whether it was possible to cache PHP and through that question was introduced to the concept of PHP accelerators, specifically APC. Well, doing lots of research online, I feel like a newbie once again, as all of the “behind the PHP curtain” lingo sounds like Ancient Greek. So…I think that it’s time to buy a book on optimizing my PHP so that I can eventually ask some meaningful questions.

My question, then is whether anyone has any recommendations. Through another thread, the book Advanced PHP programming by Schlossnagle was mentioned. But, before I go off and buy it, I’d love to what your opinion is on the matter.

Thank you,

Eric

It sounds like you want to optimise your app before knowing what needs to be optimised.

It is sounding suspiciously like premature optimisation.

I don’t fully agree with people who say that premature optimisation is the root of all evil, but I will say that you at least have to have an understanding of what needs to be optimised, before you go ahead and do so.

Caching techniques in PHP aren’t just applicable to PHP. You can cache things in lots of different ways, just like with any other server-side environment. You can cache things in memory based storage like memcached, you can cache things in temporary files, you can cache the output of full pages or data retrieved from individual database queries. Before you go crazy with caching, you need to know what needs caching the most. What are your slowest queries? Can they simply be sped up, rather than resorting to caching? What would and would not benefit from caching?