Web Development‎ > ‎

PHP Cache

The gadget spec URL could not be found
The gadget spec URL could not be found

Since PHP is an interpreted language, every page access has to load the script, parse it, compile it into op-codes, then execute it.

This load/parse/compile cycle can add up to a lot of processing time, specially when you have lots of page accesses.

Op-code caches/accelerators eliminate this load/parse/compile time, by doing so once, and keeping the compiled version of the script in memory (or disk) and use it next time a page requests this script.

This has two main benefits:
  1. Page processing times can be much less in many cases

  2. Decreased load on server resources, mainly CPU time and memory consumption, which is important for a large site, or when a site suffers the Slashdot Effect
These are compelling reasons to use an op-code cache.

Of course, an op-code cache will not help your site if your bottleneck in not CPU or memory. For example, if your bottleneck is in the database, or disk, the op-code cache will not directly help. However, since scripts start and end faster than without one, you may experience less contention in some cases.

Install a PHP op-code cacher like XCache or e-Accelerator or APC

PHP Caches


XCache is fairly new, although it seems to have momentum behind it



APC is maintained by core PHP developers, including Rasmus and others. APC does not utilze a disk cache, unlike both eAccelerator and XCache (although it is configurable)