Support » Plugin: W3 Total Cache » Multiple WP installs on same domain with APC object cache

  • The setup i run has a number of WP sites in subdirectories.

    example.com/blog1
    example.com/blog2

    etc

    Each site runs W3 with object caching (APC).

    I see the following data stored in APC User Cache entries:
    w3tc_example.com_object_39ac2157471c48cb04e93f25bae68eb8
    …(and many more)

    What concerns me is that only the domain part (example.com) prefixes the object names.

    Is it possible for installs to interfere between each other with this configuration? If so, are there any workarounds?

    http://wordpress.org/extend/plugins/w3-total-cache/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Stanislav Khromov

    (@khromov)

    Have looked into this further.

    Object Cache seems bound to collide, because the APC key is calculated as follows:
    $key = sprintf(‘w3tc_%s_object_%s’, $host_id, md5($group . $id));

    $group = option type (option, transient)
    $id = unique key for the option, (is_blog_installed, get_bookmarks etc)

    There is nothing setting apart an install at
    /blog1 and
    /blog2 on the same domain, since the have the same keys ($id)

    Page Cache seems safe. It is calculated as:
    $key = sprintf('w3tc_%s_page_%s', w3_get_host_id(), md5($key));

    $key = a path, starting from the domain root, ie /blog1/page

    Since the full link to the path is provided including the blog path, this should be safe.

    Database Cache is also safe, since every query has the database name in it, which is unique for each install.
    $key = sprintf('w3tc_%s_sql_%s', w3_get_host_id(), md5($sql));

    $sql = the db query, ie:
    SELECT sitedb_posts.* FROM sitedb_posts WHERE sitedb_posts.post_type = ‘page’

    Perhaps Object Cache could take in account the absolute path of the WP install?

    Would be great if someone could clarify the issue with object cache and provide some input.

    Perhaps Object Cache could take in account the absolute path of the WP install?

    I had the same problem and ended up doing that. It took a small change to W3TC 9.2.4 to make it work for me.

    http://technology.bernews.com/w3tc-caching-and-multiple-wordpress-installations/

    Thread Starter Stanislav Khromov

    (@khromov)

    Hey laurionb.

    Checked your post, glad someone else has found the issue.

    Your workaround seems fine. I have opted to disable object caching altogether to avoid breaking stuff when W3 gets updates.

    You should not need to modify the query or page cache calculations as they contain values unique to the installation. Only Object Cache is affected by this.

    The latest version has improved key generation. It can be modified if that is desired. module can be database cache, page cache, or object cache:

    public function get_item_key($name) {
           $key = sprintf('w3tc_key_%s_%d_%s_%s', $this->_host, $this->_blog_id, $this->_module, $name);
            /**
             * Allow to modify cache key by W3TC plugins
             */
           $key = w3tc_do_action('w3tc_' . $this->_module . '_cache_key', $key);
           return $key;
       }
    Thread Starter Stanislav Khromov

    (@khromov)

    Thanks Frederick,

    I’m trying to implement a directory-based check (md5 of the WordPress ABSPATH)

    I’m having issues. Some items never get hits in the cache, and some items are created without passing through my hook. I think you need to hook the w3tc_add_action to a certain hook in WordPress, can you advise which one?

    Right now I just have this code below in an mu-plugin I made:

    <?php
    w3tc_add_action('w3tc_object_cache_key', 'w3tc_better_object_cache_key');
    
    function w3tc_better_object_cache_key($in)
    {
    	$new_key = $in . '_' . md5(ABSPATH);
    	return $new_key;
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multiple WP installs on same domain with APC object cache’ is closed to new replies.