Support » Plugin: WPtouch » WPTouch Pro and Varnish

  • Resolved wp-touch_varnish


    We have several WordPress sites behind a Varnish Server and the sites running WPTouch Pro are serving up the mobile theme to desktop clients and the desktop theme to mobile clients. This is only occurring with WPTouch Pro as WPTouch lite is functioning properly and so are other mobile theme solutions.

    We have separated out the mobile users by their user agents and hashed the mobile users cache separately in Varnish. This is happening on different versions of WordPress (3.5.1, 3.4,2) with different versions of WPTouch Pro(2.7.2, 2.8).

    Any suggestions are appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Caching plugins and services (such as Varnish) tend to overwrite your desktop theme with posts and pages stored using your mobile theme (and vice-versa). Until caching software can recognize the theme being used, we offer support to assist you in disabling them from activating when mobile devices are detected. This will allow you to see your mobile theme on mobile devices and your desktop theme on desktop browsers as expected.

    Our customer support documentation covers most of the popular caching plugins. For the free version of WPtouch, enter the user agents found under Advanced Options > Custom User-Agents to the “rejected user agents” areas in your caching software’s settings. Remember to clear your plugin, service, browser, and device caches before retesting.

    As caching has little to do with WPtouch or WPtouch Pro, beyond providing guidelines for setup, we are unable to provide additional support for third-party products and services. If one caching plugin or service isn’t working well with your WordPress configuration, we recommend contacting the developer and/or trying another.

    Remember that your WPtouch Pro license gives you support for your installation. Log in to your account at to get started.

    Just noticed this question.

    Varnish easily caches a separate mobile version of the site by identifying the user agents, factoring in cookie (if switch to desktop) and adding a variation to the hash. No issues whatsoever. Works way faster than a pass through.

    I can share my vcl once I get a bit free.



    Vidyut, Any chance you can share those Varnish rules?


    I am so sorry for abandoning this post.

    I have posted my current config here

    It is working fine with wordpress, modpagespeed / ngx_pagespeed and wp-touch.

    I am currently not using wp-touch for the most stuff, so I have taken ut the exact code for the switcher. This code will give you browser recognition and separate caches as per capabilities and serve appropriate content automatically. But it won’t allow for switching. I will need to install wp-touch and find the string for switching (seeing mobile site from desktop or vice versa). Basically, what I had done was once I have the string, I just add a pass for it.

    It is possible to switch the type of device instead of passing through, but I never had the kind of traffic that would force me to cache those few queries.

    If you are not using pagespeed (or not serving special features by user agent like lazy load images), you could keep just two variants – desktop and mobile – and shift other user agents into one or the other as you see fit (make everything not mobile into desktop and you should be fine). That will take out two sets of caches.



    Thanks for sharing, @vidyut

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WPTouch Pro and Varnish’ is closed to new replies.