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 );
}
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?
There aren’t any plugins needed for W3TC right now. It’s there for some special uses that aren’t yet popular.