On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
> With this question, I aim to understand the inner workings of PHP a
> little better.
> Assume that you got a 50K library. The library is loaded with a bunch
> of handy functions that you use here and there. Also assume that these
> functions are needed/used by say 10% of the pages of your site. But
> your home page definitely needs it.
> Now, the question is... should you use a global include that points to
> this library - across the board - so that ALL the pages ( including
> the 90% that do not need the library ) will get it, or should you
> selectively add that include reference only on the pages you need?
> Before answering this question, let me point "why" I ask this question...
> When you include that reference, PHP may be caching it. So the
> performance hit I worry may be one time deal, as opposed to every
> time. Once that one time out of the way, subsequent loads may not be
> as bad as one might think. That's all because of the smart caching
> mechanisms that PHP deploys - which I do not have a deep knowledge of,
> hence the question...
> Since the front page needs that library anyway, the argument could be
> why not keep that library warm and fresh in the memory and get it
> served across the board?
> When answering this question, please approach the matter strictly from
> a caching/performance point of view, not from a convenience point of
> view just to avoid that the discussion shifts to a programming style
> and the do's and don'ts.
> Thank you
Since searching for files is one of the most expensive (in time)
operations, you're probably best off with only a single PHP file. PHP
parses a file initially pretty quickly (it's only checking syntax half
on load), so unless you're having a 100MHz CPU with SSD drive, I'd say
go with a single PHP file. If you make sure the file isn't fragmented
over your disk, it should load pretty quick to memory. I'm not sure if
PHP caches that much, but if you really care, take a look at memcached
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php