Caching always loading files in PHP

In my index.php file I always load some classes used later. From profiler it states it sometimes can take about 20% of entire code. Is there any improvement that can make this process faster?

I would try to make this list of classes shorter, but app is very big and checking all dependencies will be costly.

10.12.2008 21:35:16

You might want to look at apc

10.12.2008 21:41:13

Op-code caches such as APC and eAccelerator store a compiled version of your scripts in a cache. This dramatically reduces memory usage and loading time for frequently used static scripts.

10.12.2008 21:43:43

While using an opcode cache (such as APC) will reduce the impact of loading/parsing/compiling the class, you'll still be loading them all on every page load & doing whatever initialization accompanies a require_once() call. If you were to set up an autoload function then the classes won't be loaded until your code actually needs to use them. There's a little overhead involved in using a class autoloader but it makes the code easier to maintain.

As always, YMMV, so benchmark your application to see if it's worthwhile in your case.

10.12.2008 22:14:36