• Short question: How do I make w3 create a separate page cache for each theme that is served?

    Long Question:
    I’ve been stumped for a while now on this, and in the end had to disable page caching completely on any site i have that has a mobile theme switcher. Basically what happens is after you clear the cache, if the first visit is mobile, the mobile site gets cached. Then subsequent desktop visits get the mobile site as well. Or vice versa if the first page view after the cache was cleared is from a desktop browser.

    AMTS (Any Mobile Theme Switcher) claims to have solved this issue, and after purchasing their pro version, i found out they have not, and the claim is a lie. I have even received a demo site from the plugin creator, and it has the exact same problem, see for yourself here:
    http://projects.designerdady.com/dinesh_test
    Proof in this screenshot. The three mobile browsers on the left (iOS, Android & Blackberry) all load the desktop site (albiet it is responsive, so it isn’t terrible, but it is not loading the correct theme!)
    https://dl.dropboxusercontent.com/u/39497/Screen%20Shot%202013-08-09%20at%2012.40.58%20PM.png

    There is an old thread here that has long since been closed and become outdated, here:
    http://wordpress.org/support/topic/w3-total-cache-switch-between-mobile-themes-and-desktop

    The idea would work perfectly except w3 has changed a lot since then, and there is no functions.php file anymore.

    Other solutions that i have found involve disabling page caching for mobile by adding a list of user agents to the rejected user agents box in w3 page caching settings. IMHO this is a stupid solution, because now we are just avoiding page caching and circumventing the awesomeness of w3! Furthermore this is mobile, which is already slow enough (slow mobile networks, etc), so we are just giving the mobile users a bad experience.

    I’m getting really frustrated, i’ve been looking everywhere for a solution to this. Any advice would really be appreciated!

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • ron cyrier

    (@roncyriergmailcom)

    did you ever find a solution for this? I’m getting an issue with my site too. I have some ISMobile logic which is out of wack when using W3 Total Cache.

    msteel

    (@msteelnapcocom)

    I’ve been researching this on an off for a couple of years and am finally in absolute need of it. I’ve seen lots of posts about people wanting this feature but no results.

    I hate to alter the plugin but going through the code I’ve found onc place to make a simple override.

    In /wp-content/plugins/w3-total-cache/lib/W3/mobile change line 21 from

    return isset($_SERVER[‘HTTP_USER_AGENT’]) && preg_match(‘~’ . $group_compare_value . ‘~i’, $_SERVER[‘HTTP_USER_AGENT’]);

    to

    return isset($_SERVER[‘HTTP_USER_AGENT’]) && preg_match(‘~’ . $group_compare_value . ‘~i’, $_SERVER[‘HTTP_USER_AGENT’]) && ! isset( $_COOKIE[‘w3tc_mobile_override’] );

    Then you just need to write the code to set and delete the cookie.

    I haven’t decided whether to take this approach, but it seems to be the most non-invasive way to handle this.

    (also I tried to apply a filter to the cookie name but it kept causing a fatal error, could be this code is being called before that functionality is loaded)

    msteel

    (@msteelnapcocom)

    Here’s another post asking the same thing, Frederick says, “You can simply disable the groups.” Obviously disabling the groups overall is not what people want. If there’s a way to switch off that config on the fly with a filter of some sort I have not found it.

    http://wordpress.org/support/topic/overriding-w3-total-cache-user-agent-group-theme-choice?replies=4

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘W3 Total Cache & Mobile Theme Switching’ is closed to new replies.