Caching is always loading files in PHP

In my file, index.php

I always load some classes to be used later. From the profiler, he states that sometimes it can take up about 20% of the whole code. Are there any improvements that can speed up this process?

I would try to make this list of classes shorter, but the application is very large and checking all dependencies would be costly.

0


source to share


3 answers


Op-code caches such as APC and eAccelerator store the compiled version of your scripts in a cache. This significantly reduces memory usage and load times for frequently used static scripts.



+2


source


By using an operation cache (like APC) the impact of loading / parsing / compiling the class will be reduced, you will still load them on every load on the page and do any initialization when you call require_once (). If you were to create an autoload function , then the classes will not be loaded until your code can use them. There's a bit of overhead associated with using a class autoloader, but it makes the code easier to maintain.



As always, YMMV, so compare your app to see if it's worth it in your case.

+2


source


You might want to look at apc php.net/apc

0


source







All Articles