• Resolved BerryReview

    (@rhalevy)


    I absolutely love the W3 Total Cache plugin but I am having trouble with trying to pull off something a bit more complex. I am using the built in user agent switcher to give mobile devices a mobile theme and desktop devices a desktop theme. The thing is I want to add a tiny bit more functionality.
    I was using WordPress Mobile Pack to allow users to switch between the mobile and desktop theme but then it would mess up the mobile cache with a desktop theme. I could reject a cookie somehow but then I would lose the caching for that page and it would keep on not caching their pages until that cookie is removed.
    I am also interested in offering a higher fidelity mobile site for devices with WebKit browsers and I want to allow users to choose to use this new theme and have that theme cached.
    In short I am wondering how I can allow user agents to switch themes and still cache that theme. Any ideas how I can go about doing such a thing?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter BerryReview

    (@rhalevy)

    PS I am also having another issue where W3 Total Cache is caching the mobile site for desktop visitors sometimes. Really annoying and I have not found a way to debug it…

    we have these functions in a file in the plugins folder of w3 total cache plugin.

    what they do is make different versions of the page cache based on which browser comes to the site. (for us its IE and everyone else)

    If you want to modify the code for it to do store different versions for mobile browsers only it shouldn’t be that hard. But I can’t offer more help than this.

    /**
     * Makes different page cache keys based on user agent
     *
     */
    function liberal_w3tc_pgcache_cache_key($key){
        global $is_IE, $is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
    
        liberal_w3_detect_browser();
    
        $postfix = "";
        if($is_winIE) {
            $postfix = "winIE";
        }
    
        if($postfix) $key .= "_" . $postfix;
    
        return $key;
    }
    w3tc_add_action('w3tc_pgcache_cache_key', 'liberal_w3tc_pgcache_cache_key');
    
    /**
     * Simple browser detection
     * This code is copied from wp-includes/vars.php because we need it for W3 total cache which is loaded before wp-includes/vars.php
     *
     * @see wp-includes/vars.php:37
     */
    function liberal_w3_detect_browser() {
        global $is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE;
        $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
    
        if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
            if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) {
                $is_lynx = true;
            } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'chrome') !== false ) {
                $is_chrome = true;
            } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false ) {
                $is_safari = true;
            } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) {
                $is_gecko = true;
            } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) {
                $is_winIE = true;
            } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) {
                $is_macIE = true;
            } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) {
                $is_opera = true;
            } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) {
                $is_NS4 = true;
            }
        }
    
        if ( $is_safari && stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false )
            $is_iphone = true;
    
        $is_IE = ( $is_macIE || $is_winIE );
    }
    Thread Starter BerryReview

    (@rhalevy)

    The functions file of W3-Total-Cache seems to be totally empty. I checked the wordpress trunk and its empty there too.
    http://plugins.svn.wordpress.org/w3-total-cache/trunk/plugins/
    What gives?

    Plugin Contributor Frederick Townes

    (@fredericktownes)

    There aren’t any plugins needed for W3TC right now. It’s there for some special uses that aren’t yet popular.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘W3 Total Cache Switch Between Mobile Themes and Desktop’ is closed to new replies.