Selective APC usage with nginx

Events happening in the community are now at Drupal community events on www.drupal.org.
DrakeTaylor's picture

I have a 256meg slice on slicehost running a drupal 6 site using nginx and APC. Everything works perfectly. However, I want to add a private site just for me and have that site not be cached by APC. I've searched online and found how to do it using apache, but not nginx. Any ideas on how to get APC to cache only the public site?

Thanks.

Comments

Are you talking about code

brianmercer's picture

Are you talking about code cache or data cache?

You can exclude code by stating some unique part of its path in /etc/php5/conf.d/apc.ini using:

apc.cache_by_default=1
apc.filters="-secondsite"

It should be the same for apache.

Thanks Brian, I was thinking

DrakeTaylor's picture

Thanks Brian,

I was thinking more of turning apc off in php.ini and using .htaccess to turn it on for a specific site. But I'll try this instead.

Thanks again!

-Drake

You can try this.

perusio's picture

That avoids fiddling with the APC config file.

  1. At the http context of your Nginx config.

    map $http_host $apc_state {
      hostnames;
      default "apc.enabled=1";
      private.site.com "apc.enabled=0";
    }
  2. And now define a fastcgi_param like this:

    fastcgi_param PHP_ADMIN_VALUE  $apc_state;

Try it out. It should work. Don't know if it will work with php-cgi, but should work with a moderately recent version of php-fpm.

That's a cool way to do it.

brianmercer's picture

That's a cool way to do it.

Even more cooler :)

perusio's picture

http {
...
    map $http_host $apc_state {
       hostnames;
       default 1;
       my.private.site.com 0;
    }
...

Then the fastcgi_param:
fastcgi_param PHP_ADMIN_VALUE  "apc.enabled=$apc_state";

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: