Preparing for Google’s Mobile Friendly update (opens in a new tab) on April 21st, we noticed that some of our clients’ sites using the WPTouch plugin (opens in a new tab) were unexpectedly failing Google’s mobile-friendly test (opens in a new tab). Since all of the sites were hosted with WPEngine (opens in a new tab), 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!
Categories:
Resources