apc.filters syntax - anybody ever get it working?

WebEndev

Member
I have been working on optimizing my APC settings. It has been going well for the most part, with one exception.

I am trying it exclude a directory from the APC cache, and am trying to use the apc.filters setting to do it. I have read the documentation on the setting, and also scoured the internet for working examples. But to no avail, I cannot make it work - no matter what I try, it is still including my directory in the cache.
The syntax for apc.filters is supposed to be regular expressions - and I struggle to understand them beyond simple usage.

So my directory is located on this path in the server:

/home/my_user/public_html/my_directory

I have tried about a dozen combinations including:
apc.filters = /my_directory/
apc.filters = /home/my_user/public_html/my_directory
apc.filters = /my_directory/.*
and more....

Can anyone out there help me with the correct syntax?

(P.S. - I did put in a ticket with KH support on this, and they pretty much looked to me for the solution and didn't offer anything).

Thanks!
 
WebEndev,

I don't have any experience using these filters - I do however have a working knowledge of RegEx.

Using direct file paths would be correct RegEx since nothing in a standard path has to be escaped.

When you were using the exact paths, ex.

Code:
apc.filters = /my_directory/
apc.filters = /home/my_user/public_html/my_directory


Were these not working at all?
 
Hi Jonathan,

No, they did not work at all. I tried those, plus about 10 other variations.

The docs for apc.filters (http://www.php.net/manual/en/apc.configuration.php#ini.apc.filters) is very confusing to me:
A comma-separated list of POSIX extended regular expressions. If any pattern matches the source filename, the file will not be cached. Note that the filename used for matching is the one passed to include/require, not the absolute path. If the first character of the expression is a + then the expression will be additive in the sense that any files matched by the expression will be cached, and if the first character is a - then anything matched will not be cached. The - case is the default, so it can be left off.

Especially this part:
Note that the filename used for matching is the one passed to include/require, not the absolute path.

In all of my searching on this, I have found some people that say apc.filters will only work by file type, and other people that say directories can be excluded. The problem is, I cannot find a working example of how to exclude a directory :(

So I thought I would come here and see if anyone in the forum had used apc.filters in excluding a directory before.

Thanks for your help.
 
Note that the filename used for matching is the one passed to include/require, not the absolute path.

most likely it means that php uses "relative" path/name for pattern matching

for example your include directory is /var/www/site1/includes which is configured as include path.
"absolute" path on the filesystem to a file is /var/www/site1/includes/library/file1.php

your script includes the file as
Code:
require once "library/file1.php";

and this "library/file1.php" string will be used for matching, not the absolute path. I'd try to use

Code:
apc.filters = "-library/file.php"; // single file
 
apc.filters = "-library/.*"; // whole directory
 
Hello Dmitry,

So in my case it would be this, correct?

Code:
apc.filters = "-my_directory/.*"; // whole directory
 
Hello Dmitry,

This DID work!

Code:
apc.filters = "-my_directory/.*";

So now I am attempting to add one more directory exclusion, and I believe that it would be this?

Code:
apc.filters = "-my_directory/.*,-my_directory2/.*";

That is what I am trying now. I will report back.
Thank you for your help!
 
Hello Dmitry,

The multiple directory syntax worked great.
Thank you again for your help on this!
It was quite a frustration for me... o_O
 
Top