Support » Plugin: WP Mobile Detect » Not Working with W3TC

Viewing 8 replies - 1 through 8 (of 8 total)
  • I found a work-around. In W3TC under Page Cache, use the Rejected user agents field and enter all mobile user-agents. The makes the mobile-detect work, but of course it means mobile users are served non-cached (hence slower) pages. Any way around that? Sure would be nice to serve up fast, cached content to mobile users, too!

    I have the same problem, Mike. Once a page is loaded on a device, that device’s content is cached and served on every ensuing page view no matter what device you’re using. Currently looking for a workaround that doesn’t involve disabling caching entirely for mobile users. If anybody has any ideas that could help, that would be awesome!

    l w


    I’m having the same problem. There must be a solution. Jesse?

    Hi, i solved following the Mike workaround putting this mobile user agent in W3TC and, performance are still good.

    I found a solution, follow the steps:
    1 – update the php file mobile-detect.php to the last version(see, you only have to copy and paste the code.
    2 – Edit the file wp-config.php. In my case I only want to detect if the browser is a phone or not, so if you have a different situation you’ll need to change the code a little bit.
    So, before require_once(ABSPATH . ‘wp-settings.php’); add the following code:
    Change to the domain of your website
    3 – Edit the W3TC php file: /plugins/w3-total-cache/lib/W3/CacheCase.php, look for the method public function get_group() and change as the following:
    4 – At the last step you`ll have to go to W3 Total Cache Menu > User Agent Groups and create a new group named -> use_mobile_cache
    Let it enabled and the user agents field empty.

    Remember: this solution it only detect if the browser is a phone or not and the w3 total cache plugin create 2 differents cache: one for desktop and tablets and other to phones

    Hi Alatui, great fix! But I would avoid to modify core W3TC files…
    Any solution to use your get_group function outside w3tc plugin folder?

    Best way should be paste it in functions.php… any idea?

    Hi Alexander,

    Unfortunately i didn’t find other way to do this, i even tried to look for some hooks in w3totalcache but with no sucess.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Not Working with W3TC’ is closed to new replies.