Turning on APC per site

The Alternative PHP Cache (APC) is commonly used with Yii applications, as it can speed up script running time by a factor of two. Compiled code is kept in shared memory for quick and easy access instead of being compiled each time a script is ran.

The only problem this can bring, is that if you a developing a site and APC is on, you won’t see any changes in your PHP code until APC is flushed.

Yii has a development mode which will turn off APC for you, however, if you’re running your Yii site on a shared server, you don’t want APC on universally.

So, the solution is to install APC, but to only turn enable on a per site basis using .htaccess.

Assuming you’ve installed APC from PECL
edit your php.ini and turn off APC by modifying the following line

apc.cache_by_default 0

And then add the following to your site’s .htaccess or (php.ini without the ‘php_flag’ if you’re running suPHP) when you want to turn it back on.

php_flag apc.cache_by_default On

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>