• Can we have support for mobile devices in Cache Enabler?

    WP-Super-Cache allowed me to cache posts for mobile devices differently, in separate cache files. Then I could rewrite requests coming from mobile devices directly to the cache files specific for mobile, circumventing PHP execution and allowing me to do mobile device specific tricks in my WordPress site (wp_is_mobile())

    With Cache Enabler, my wp_is_mobile() tricks don’t work when a file is already cached by a personal computer visitor.

    https://www.ads-software.com/plugins/cache-enabler/

Viewing 10 replies - 1 through 10 (of 10 total)
  • We do not recommend using a separate mobile theme or plugin to create a mobile theme with Cache Enabler. This plugin was designed to work best with responsive themes where the same theme is being used whether the visitor is accessing the site via their desktop or mobile device. https://www.keycdn.com/support/wordpress-cache-enabler-plugin/#mobile-themes

    Thread Starter Jan Reilink

    (@janr)

    Thanks for your reply @codyarsenault!

    It’s not quite what I meant, and maybe I didn’t explain myself well enough. But it’s not about using a separate mobile theme or plugin to create a mobile theme (kinda). Let me elaborate:

    In WP-Super-Cache you can activate the WPTouch plugin for WPSC, without actually having WPTouch… (wait for it). Then comment out a line in plugins/wptouch.php (reference), and WPSC nicely generates static cache files for mobile devices, called index-mobile.html of example.

    Note, these are no different than ordinary WPSC static cache files, but in your .htaccess or web.config file, you can rewrite visitors using a mobile device directly to the index-mobile.html(.gz)? files.

    Doing so gives you the opportunity to use WordPress functions like wp_is_mobile() to present mobile visitors with a different user experience than ordinary computer users.

    The problem with Cache Enabler: when I use wp_is_mobile() in my theme or plugin, and a visitor using a computer visits a post first, only that variant of the post is cached. There is no way to generate a mobile version anymore.

    (please excuse the lengthy reply ?? )

    Plugin Author KeyCDN

    (@keycdn)

    The Cache Enabler does not generate a separate mobile version, which means there is no index-mobile.html. We will consider adding this in the future. Thanks a lot for your feedback.

    Thread Starter Jan Reilink

    (@janr)

    Thanks for your reply @keycdn, marking this topic as resolved.

    • This reply was modified 8 years, 6 months ago by Jan Reilink.

    You should be aware that wp_is_mobile() is generally considered a waste of time because it is easily misled. See e.g. https://wordpress.stackexchange.com/questions/188881/proper-usage-of-wp-is-mobile

    Media queries should be used instead.

    Thread Starter Jan Reilink

    (@janr)

    Hi @kts915, thank you for your reply.

    My intended use is exactly what “Sumit” states at https://wordpress.stackexchange.com/a/188897/27620:

    How WordPress use it: WordPress do not use it for styling or adding CSS anywhere. WordPress use it to add or manipulate thing which should be only on mobile devices (regardless size and name.) e.g. to add touch scripts, add viewport, mobile class in admin header, adding mobile buttons.

    To be frank (note: this is beyond the scope of this support ticket! But to eleborate the wp_is_mobile() usage) , I don’t want to display some ads on mobile devices.
    My shortcode in my own site-specific plugin to accomplish this is:

    function adsenseads300600() {
      $output = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
        <ins class="adsbygoogle"
          style="background-color: transparent;text-decoration: none;display:inline-block;width:300px;height:600px;"
          data-ad-client="ca-pub-yyyyyy"
          data-ad-slot="zzzzz"></ins>
        <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>';
        
      if ( ! wp_is_mobile() ) {
        return $output;
      }
    }
    add_shortcode('showmyads300600', 'adsenseads300600');

    My next step is to opt out from ads using a cookie, but that’ll take some more time.

    • This reply was modified 8 years, 5 months ago by Jan Reilink. Reason: blockquote formatting
    Thread Starter Jan Reilink

    (@janr)

    Hi @keycdn I created a inc/cache_enabler_disk.class.php patch with the most minimal wp_is_mobile() functionality. Interested? It still needs some testing and I’ll put up the code in a blog post sometime this week.

    Plugin Author KeyCDN

    (@keycdn)

    Hey @janr, sure just share the diff patch as gist file (or similar) with us. We can add it to our RFE to do list.

    Thread Starter Jan Reilink

    (@janr)

    Thanks for your reply. I created this inc/cache_enabler_disk.class.php.patch for you:

    https://gist.github.com/Digiover/cac8ea983856dd07b476ca915138146c

    It provides the most minimal wp_is_mobile() support for Cache Enabler.

    guenstig-kochen.at

    (@guenstig-kochenat)

    @janr

    — update —
    made it ??
    works like a charm now!
    that’s exactly what’s missing in this plugin
    ————–

    where do I put your code?

    regards from austria

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Mobile device support’ is closed to new replies.