Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

Setting up APC. Caching in php.

17/04/2025, by Ivan

!!! Warning !!! Do not use APC if you're running PHP version 5.5 or higher—OPCache replaces APC and is built into PHP.

On March 21, 2013, PHP 5.5 beta 1 was released including Zend OPCache—this strongly suggests that OPCache is the official replacement for APC, as it’s included in the PHP core and must be maintained with every new PHP release.

APC (Alternative PHP Cache) caches PHP opcode. As its developers describe it: "APC is a free, open, and robust framework for caching and optimizing PHP intermediate code."

PHP is a high-level language and like many such languages, it is compiled at runtime. CMSs like Drupal are composed of hundreds or thousands of scripts. Due to its modular nature, each page request may load many of these scripts. Unlike compiled languages, PHP compiles scripts into bytecode at runtime. APC helps by storing the compiled bytecode in memory, making subsequent executions much faster—critical for improving Drupal’s performance.

To install APC:

sudo apt-get install php-pear
sudo apt-get install php5-dev apache2-prefork-dev build-essential
sudo pecl install apc

Next, copy the apc.php script (provided with this lesson) to your server and restart Apache:

sudo /etc/init.d/apache2 restart

Visit http://test/apc.php to view APC statistics.

If you see lots of cache MISSes and high memory fragmentation, your APC configuration is inefficient. Possible causes:

  • Not enough memory: For example, if your scripts take 12 MB and APC is only allocated 8 MB, there won’t be enough space, resulting in MISSes.
  • Fragmentation: Even with 32 MB allocated, fragmented memory may prevent APC from storing larger scripts efficiently.

APC configuration file (Debian/Ubuntu): /etc/php5/conf.d/apc.ini

apc.enabled=1

Enables APC. Disabling this may degrade performance on production servers.

apc.shm_segments=1
apc.shm_size=32

These settings define shared memory segments. Increase apc.shm_size if MISSes remain high (e.g., try 64, 128 MB).

apc.cache_by_default=1
;apc.filters=

Enables APC caching for all PHP scripts. Comment out apc.filters to allow universal caching.

apc.cache_by_default=0
apc.filters="+drupal6"

This restricts APC caching to only Drupal 6 files—useful if you want to exclude tools like phpMyAdmin from being cached.

apc.stat=1

With this enabled, APC checks file modification times. Disable for production; enable for development. When enabled, remember to clear APC cache after updates.

apc.ttl=0

TTL for cached entries. 0 means entries are never expired automatically (default is 7200 seconds).

apc.rfc1867=1

Enable file upload progress tracking via APC in Drupal.

apc.num_files_hint=2048

Helps when multiple Drupal sites are hosted. A single Drupal install may load 500+ files. Set this higher to prevent one site from overwriting another's cache.

After changing settings, restart your server. Optimal graphs should show low MISS count and 0% fragmentation.