• Resolved Biranit

    (@biranit)


    Hi,

    We have mobile device support turned on, as well as a plugin that serves a different theme for desktop and mobile.

    By default, WPSC’s list of mobile devices includes iPad – which isn’t mobile, it’s tablet, and in many cases (as in ours) gets served either its own theme or desktop.

    So this creates a problem: an iPad user who visits the a page that isn’t cached, gets served a desktop version – that WCSP then stores as a mobile cached version, and then serves this to other mobile users…

    I edited wp-cache.php to remove iPad, however I believe it’s something that is inherently a mistake by the coders, and I’m also unsure if there are other tablet strings that appear there.

    I’d also like to suggest that you separate mobile and tablet user agents, and also urge you to allow the user agent lists to be edited in the WPSC advanced settings page.

    FYI, you also have super ancient and irrelevant user agents listed there. I recommend Cloudflare’s regex match for device type detection:

    • Mobile: (?:phone|windows\s+phone|ipod|blackberry|(?:android|bb\d+|meego|silk|googlebot) .+? mobile|palm|windows\s+ce|opera\ mini|avantgo|mobilesafari|docomo)
    • Tablet: (?:ipad|playbook|(?:android|bb\d+|meego|silk)(?! .+? mobile))
    • Desktop: Everything else not matched above.

    Finally, I just want to verify: the change I made to super-cache.php will not be erased when/if I upgrade WPSC, correct?

    Many thanks,

    Bira

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @biranit. Unfortunately any changes you make to wp-cache.php will be lost when the plugin updates.

    However, you can use the “cached_mobile_browsers” WordPress filter to remove “ipad” from the list of mobiles browsers. You’ll create the filter in a separate file, maybe in wp-content/mu-plugins/ and remove the “ipad” value from the array of mobile browsers.

    Thread Starter Biranit

    (@biranit)

    Hi @donncha , Good to see you here 🙂

    I ended up using MobileESP – which is really great and very accurate – in this manner (in my theme’s functions.php):

    if (function_exists('add_cacheaction')) {
    	function rgb_wp_cache_check_mobile($cache_key) {
    		include_once('/path/to/mobile-esp.php');
    		$ua = new uagent_info;
    		return ( $ua->DetectMobileQuick() ) ? 'mobile' : 'normal';
    	}
    	add_cacheaction('wp_cache_check_mobile', 'rgb_wp_cache_check_mobile');
    }

    It works very well and solved all my issues. What do you think? Is this a viable workaround?

    Thank you 🙂

    That’s a good idea! I’d put that chunk of code in a file in wp-content/mu-plugins/ because you might forget to move it if you change themes.

    Thread Starter Biranit

    (@biranit)

    Thank you @donncha ❤️

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WPSC recognizes iPad as mobile’ is closed to new replies.