Preparing for Google’s Mobile Friendly update on April 21st, we noticed that some of our clients’ sites using the WPTouch plugin were unexpectedly failing Google’s mobile-friendly test. Since all of the sites were hosted with WPEngine, we contacted both WPTouch and WPEngine support. After a bit of back and forth, WPEngine solved the problem by adding the following to the varnish cache for the affected sites.
set $mobile_bot 'no';
if ($http_user_agent ~* (iPhone) ) {
set $mobile_bot "X";
}
if ($http_user_agent ~* (Googlebot) ) {
set $mobile_bot "${mobile_bot}Y";
}
if ($mobile_bot = "XY"){
set $is_bot 0;
}
If you’re having a similar problem passing the mobile friendly test and use WPTouch and WPEngine, try it out!