Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APC and PHP - Broken Sites Due to Cache Mixing

I hope someone can give me a hand figuring this out. I have been running APC recently on some of my servers that host only one application and it's been working great. Unfortunately I went to run it tonight on my workhorse web server and as soon as I turned it on I started getting 'mixing' from my wordpress blogs. The first blog to get loaded would cache database information and then every blog loaded later would get a database error.

What I want to know is if there is a way to prefix the cache somehow so that I can avoid this problem. I assumed that the cache would respect the differences in absolute pathing between the files and not use the same cached copy on multiple sites... FAIL

Thanks in advance!

Update

As requested here is a copy of the apc.ini file that I use in /etc/php.d/ to override default settings:

/etc/php.d/apc.ini

extension=apc.so
apc.shm_size                    = 64M
apc.max_file_size               = 8M
apc.include_once_override       = 1
apc.stat_ctime                  = 1
like image 213
Shane Avatar asked Apr 17 '11 05:04

Shane


3 Answers

As far as i knnow you cannot use global settings to set prefix for different applications. You could change your key names and add prefix to its names. If youre more skilled you could use two different instances of php using fastcgi, depending on what http server youre using. We're doing something like that using APC and ngix :)

like image 156
kkszysiu Avatar answered Nov 07 '22 09:11

kkszysiu


Have you tried setting apc.file_md5 to On? Other directives that might make a difference:

  • apc.canonicalize (If on, then relative paths are canonicalized in no-stat mode.)
  • apc.preload_path (No idea, really...)

Depending on your objective, I believe that either apc.file_md5 or apc.canonicalize will help.

like image 4
Alix Axel Avatar answered Nov 07 '22 09:11

Alix Axel


Is wordpress adding the cache entries to save DB requests? If so you will need to edit the cache library file to include a prefix.

I am guessing you are using a wordpress plugin? If so which plugin?

like image 2
instigator Avatar answered Nov 07 '22 10:11

instigator