WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] Page Cache not working - hostname mismathc (4 posts)

  1. Jawillde
    Member
    Posted 2 years ago #

    We are running a load balancing server in front of 2 Apache webservers and 1 memcachedD server.

    When running debug mode on page cache, we get an error that the page cache is disabled (though enabled in W3 settings) and the page is not cached due to a hostname mismatch.

    Disabling "Cache requests only for godfatherpolitics.com hostname" does enable the cache and our website is blazing fast, but we run 3 different WordPress installations across 3 separate domains but the cached pages begin to swap across domains and visitors start seeing xyz.com content on yyy.com so we had to disable that option.

    Here is the full debug for page cache:

    Served from: godfatherpolitics.com @ 2011-09-28 13:01:20 -->

    <!-- W3 Total Cache: Page cache debug info:
    Engine: memcached
    Cache key: w3tc_10.181.135.115_1_page_e94d0037a44a1dc6c01634e2a91f00e0
    Caching: disabled
    Reject reason: Hostname mismatch
    Status: not cached
    Creation Time: 0.230s
    Header info:
    X-Pingback: http://godfatherpolitics.com/xmlrpc.php
    Content-Type: text/html; charset=UTF-8
    X-Powered-By: W3 Total Cache/0.9.2.5b
    Link: <http://godfatherpolitics.com/?p=1176>; rel=shortlink
    -->

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

  2. Jawillde
    Member
    Posted 2 years ago #

    Hopefully this will help others and maybe Frederick Townes can add the ability to allow user to input a unique prefix in a future update to the plugin.

    When running multiple domains through one memcached server you have a cache key problem. Nothing in W3 Total Cache allows you to define the key in anyway. So website xyz.com and abc.com may have cached pages with the same key. One overwrites the other and then both abc.com and xyz.com display abc.com instead of its own respective page. The reason for this is because all the cache keys start with w3tc_ instead of some website specific key and then it is all being served from a memcached server with one hostname. I imagine most use an internal IP for their memcached server since it doesn't need to be open to the public.

    There is probably a server side solution to this, but my hosting company either doesn't know how to do this or has our memcached server misconfigured. But, either way, I needed a solution now.

    My solution (and it may not be perfect or correct but is working so far) is to find all of the cache keys and change the prefix from w3tc_ to something of your choosing. For abc.com you may decide to use abc_ for your prefix. You may also need to disable "Cache requests only for hostname" in page cache options.

    The files that I have so far found the cache key prefix in are found in w3-total-cache/lib/W3/

    PgCache.php
    ObjectCache.php
    Db.php
    Minify.php

  3. Jawillde
    Member
    Posted 2 years ago #

    Just in case anyone is actually following this thread:

    The server-side solution is to configure multiple Memcached bins on your Memchached server. Assign a different port number for each bin and set that port on your different domains. This way you don't need to modify any files if you're running a MemcacheD server.

    Thanks to Rackspace for this solution. Awesome support there.

  4. rick4him
    Member
    Posted 1 year ago #

    I'm following along. I'm wondering if I should select Cache requests only for domain)

    is something I should turn on or off?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic