apc.filters syntax - anybody ever get it working?

Discussion in 'Linux VPS/Dedicated - cPanel' started by WebEndev, Jun 17, 2013.

  1. WebEndev

    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:


    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).

  2. KH-Jonathan

    KH-Jonathan Director of Managed Services Staff Member


    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.

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

    Were these not working at all?
  3. WebEndev

    WebEndev Member

    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:
    Especially this part:
    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.
  4. KH-Dmitry

    KH-Dmitry Administrator Staff Member

    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
    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

    apc.filters = "-library/file.php"; // single file
    apc.filters = "-library/.*"; // whole directory
  5. WebEndev

    WebEndev Member

    Hello Dmitry,

    So in my case it would be this, correct?

    apc.filters = "-my_directory/.*"; // whole directory
  6. WebEndev

    WebEndev Member

    Hello Dmitry,

    This DID work!

    apc.filters = "-my_directory/.*";
    So now I am attempting to add one more directory exclusion, and I believe that it would be this?

    apc.filters = "-my_directory/.*,-my_directory2/.*";
    That is what I am trying now. I will report back.
    Thank you for your help!
  7. WebEndev

    WebEndev Member

    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

Share This Page