WordPress.org

Forums

Wp-Supercache and mobile templates (5 posts)

  1. JeanPaulH
    Member
    Posted 7 years ago #

    Hi Donncha,

    I’ve been meaning to ask this since I first installed WP-SuperCache (the first beta). I have two special templates for mobile phone users. One is for the Apple iPhone called iWPhone (obviously for my blog) and the other one is for pda and mobile phone users called WordPress Mobile. Both plugins use browser sniffing to serve a special template. I just can’t get this to work with whatever caching plugin I use (and have used). Normal desktop users sometimes get the mobile optimized template (served from the cache), more often than not mobile users get the normal desktop template. WP-(Super)Cache kicks in way before these plugins are called and so I’m forced to turn these plugins off (and send the desktop version to mobile users, for which I’m getting alot of angry complaints).

    My question: could you please find out a way to differentiate between ‘desktop’ and ‘mobile’ users and send mobile users to the proper plugin/theme instead of serving the desktop cache??? I’ve been searching for this solution ever since, but nobody seems to be willing to solve this dilemma once and for all.

    I’ve read about the non-cache calls, but to be honest that’s way above my head Any solution would be much much appreciated!

    Kind regards,
    -Jean-Paul

    (as copied from http://ocaoimh.ie/2007/11/26/digg-users-will-love-this/)

  2. Donncha O Caoimh
    Member
    Posted 7 years ago #

    The simplest way of doing it would be to check the user agent in your .htaccess and if it's not a mobile one then perhaps serve the super cached file, or the other way around depending on your traffic.
    Likewise, you'd have to write a small super cache plugin that would only create super cached files for the type of visitor you want.

    I know next to nothing about mobile user agents and don't have the time to look into it, sorry.

  3. MegaZone
    Member
    Posted 7 years ago #

    The WP Mobile plugin has a function to check for mobile user agents, this is the list:

    $small_browsers = array(
                    '2.0 MMP'
                    ,'240x320'
                    ,'AvantGo'
                    ,'BlackBerry'
                    ,'Blazer'
                    ,'Cellphone'
                    ,'Danger'
                    ,'DoCoMo'
                    ,'Elaine/3.0'
                    ,'EudoraWeb'
                    ,'hiptop'
                    ,'KYOCERA/WX310K'
                    ,'LG/U990'
                    ,'MIDP-2.0'
                    ,'MMEF20'
                    ,'MOT-V'
                    ,'NetFront'
                    ,'Newt'
                    ,'Nintendo Wii'
                    ,'Nitro' // Nintendo DS
                    ,'Nokia'
                    ,'Opera Mini'
                    ,'Palm'
                    ,'Playstation Portable'
                    ,'portalmmm'
                    ,'Proxinet'
                    ,'ProxiNet'
                    ,'SHARP-TQ-GX10'
                    ,'Small'
                    ,'SonyEricsson'
                    ,'Symbian OS'
                    ,'SymbianOS'
                    ,'TS21i-10'
                    ,'UP.Browser'
                    ,'UP.Link'
                    ,'Windows CE'
                    ,'WinWAP'
            );
  4. Adding this into the super cache conditions in .htaccess would work.

    RewriteCond %{HTTP_USER_AGENT} !^(Mobile1|Mobile2|etc|etc) [NC]

    Put the most common mobile user agents into that string and there you go.

    However, *ideally*, you would not want to use a different page for mobile users in the first place. With CSS, you can serve a different stylesheet to "handheld" users and they will see something different, even with the same page. Sadly, this does not work with the iPhone, because the iPhone is stupid like that, but it does work with most user agents. See my own blog for an example, it provides a different CSS for handheld devices.

  5. Erunafailaro
    Member
    Posted 6 years ago #

    I found a solution for this. There is no need to modify WP-Supercache.

    Instead, you only have to add a few lines of code to your wp-config.php. This is described in this great article.

    This will allow you to run one single wp-installation on two (or even more) different domains or subdomains. Each domain will have its own theme. In the backend, there is one single database.

    I have now one single WordPress-Installation available via

    Without any modification, WP-supercache keeps a separate cache for each of the two domains.

    Woot!

Topic Closed

This topic has been closed to new replies.

About this Topic