Go Mobile with Supercache

I’ll be honest, I don’t have much experience with mobile content. I’ve rarely browsed the net on a mobile device. I don’t have an iPhone and don’t intend buying one but lots of people do use mobile devices to browse online.

With that in mind, and after some pestering by Vladimir I modified WP Super Cache so it will support mobile devices and operate in full super caching mode!

The plugin now filters out requests from the most common mobile user agents and serves those requests in “half on” WP-Cache mode while serving the rest of your visitors static html files. As I’ve said many times before, the speed differences between both modes is negligible for normal traffic but it’s a nice safety net in case your site is inundated.

Only thing is, I want people to test it first before making a final release. Grab the development version from the download page and give it a whirl.
Your mod_rewrite rules in the .htaccess file have to be updated but if you delete the “WPSuperCache” rules they can be regenerated by the plugin next time you load the admin page.
There are also a number of other bugfixes and enhancements too so check out the Changelog.txt for more details.

I use WordPress Mobile Edition here and last Sunday I noticed an extra 10,000 requests from Google using odd looking “mobile useragents” like this one:

SAMSUNG-SGH-E250/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Browser/6.2.3.3.c.1.101 (GUI) MMP/2.0 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)

The actual mobile device changed but the Google bit stayed the same and all requests came from 66.249.71.2
Eventually I figured out that Google was adding my site to the “mobile” section of their index. Presumably to be served from here. Cool, another way of getting to my site.

PS. the development version also has a small modification to make it go faster by not checking file modification time on each request. This could help on really busy servers.

32 thoughts on “Go Mobile with Supercache

    1. Do you have a url to the mobile version to preview? Or it is only available when accessed via mobile device?

      I played before with Alex’s King but didn’t really see any value in it and my stats showed no traffic increase, while adding code clutter. So, just wondering here.

  1. Great to see you supporting mobile.

    Lots of techies are stand-offish about the iPhone and the prices O2 are charging in Ireland are criminal (Eur100 for 700min + 250 txts + 1GB data, whereas in the UK, where the government actually charged them far more for the 3G license, it is only Eur52 for 700min + 500 txts + unlimited data), but I have to say that, once I owned one, I was surprised to discover that mobile Internet really is a practical concept, to the extent that I often use my iPhone to surf even when just a few feet away from my desktop and 24″ monitor.

    As such, I suspect that, within the next couple of years, we will see the number of visitors using mobile devices rocket, so, it is good that WP Super Cache is ready to accommodate that.

    1. As I’m sitting at my desk for most of the day I haven’t found much use for it yet, but the one time I do is when I’m in town and looking at games. I’d love to look up the metacritic score.

      Or I could create a twitter bot that responds to requests for metacritic scores and sends a reply.. Once Tweet Tweet works again (the WP upgrade broke it, fsockopen’s at fault I think) I could tweet looking for a score!

      1. I commute about 40 minutes each way by train. As I usually don’t get a seat having a device to browse sites I read is great. Usually I just read them all from Google Reader, but if I want to comment or read more of a site it’s great if they support the smaller screens and lesser capabilities of mobile browsers.

        I’ve actually quit reading a few blogs that don’t support mobile browsing since I do a significant chunk of reading on my iphone.

        1. @Donncha

          I gather that the iPhone 3GS camera is good enough to read barcodes, will make price comparison shopping and accessing reviews much faster, although I can imagine that retailers will begin to get pretty frustrated at all the business they’re going to lose to Amazon et al.

          @Kevin

          I highly recommend the Instapaper and Tweetie apps, they’ve almost entirely replaced RSS feed reading for me.

          Tweetie lets you save shortened URLs directly to Instapaper from within the tweet i.e. without having to visit the actual page there. Instapaper lets you read the text content later, regardless of whether you are online or offline, in a very easy-to-read format, including tilt-scrolling.

          1. I check my rss feeds from multiple machines and multiple OSs. Google Reader works best for that.

            Instapaper looks interesting. I’ll pretend that you didn’t talk about twitter providing interesting content. ;^)

  2. Hi Donncha

    since updating to the devel. version with unchecked mobile support (nothing is checked in the settings) i am getting white sites sometimes, or if i hit F5.. could it be a misconfiguration from me or is there a bug somewhere?

    have a nice day

    Chris

  3. Hey Donncha,

    I upgraded to 0.9.4.3 just now on umwblogs.org, and everything seems to be running fine on the site in regards to super-cache. I disabled and earlier version about a week ago because it was conflicting with the WPTOuch plugin. This version has the modile half-on version built-in, which is excellent–thank you. The issues we are having is that when you click on a permalink it and go to a page it take you out of the mobile view and into a standard wordPress page. This may very well be the plugin, I have to search there, but I figured I would let you know.

    Additionally, my .htaccess file has some extra and slightly different code that you didn’t note in your example .htaccess file. for example, the following Rewrite conditions are not within the WP_Supercache Begin/End hashes

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . – [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    And as you’ll probably note the request_filename is -f not !-f and -d not !-d

    Also the . index.php is not . /index.php

    And within the WP-Supercache begin/end hashes, there are a few extra lines, such as:

    AddDefaultCharset UTF-8

    and

    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$

    Not sure this has any bearing on the development version, and by all accounts it i working, but do these additional lines and slight tweaks need to be added to the .htaccess to prevent any issues?

    1. Jim – check out the .htaccess rules in your admin page. It will have the extra lines you see in the supercache section plus two lines referencing mobile user agents.
      The WP rules are MU ones by the looks of things.

  4. I ran into some issues with file permissions and such, and had to reset to defaults, manually update my .htaccess files, and on one blog change the ownership on the cache files in wp-content, but after doing all that, it at least seems to be working on both, at least with the Android browser.

    I’ll keep an eye on them though.

  5. Got the wordpress-mobile-edition and will be playing with it during this whole weekend, on my first though – nice! I can visualize a website what i’ll create, hopefully I won’t hit a wall due to using JS. Getting similar mobile useragents.

  6. Hello Donncha,
    Your plugin is a life saver đŸ™‚ However I use the Lighttpd web server, which does not support apache .htaccess files. The workaround in this case is a small lua script : http://tempe.st/2008/05/lightning-speed-wordpress-with-lighttpd-and-supercache-part-ii/ đŸ™‚

    Just wanted to know whether the .htaccess rules have changed in version 0.9.4.3 and whether I would need to update the same in the lua script ?

    Thanks a lot đŸ™‚
    Abesh

    1. They’ve changed slightly. Look for the lines with the mobile user agents. Android, iPhone, etc. You’ll need to replicate those.

  7. Donncha,
    I’m on HALF-ON mode with mobile support enabled. I get to see that the compression will be enabled by default when in half on mode. As it should, there should be a compression = gzip line when I look at my source code (as I’m seeing on your page now, from a normal web browser). But I don’t see any such line in my pages’ source? Only thing I see is ‘Dynamic page generated by WSC in ….secs’ and Cache generated by Wp-super cache’. Thats all.
    As I see it, the cache is working as the numbers are changing (cached pages) each minute or so.
    Anything wrong or is this ok?

  8. Is some text changed in this post lately. Previosly I remember reading that the plugin should be in Half ON mode to support mobile edition plugin.
    Now after reading this I get that I can leave the super cache plugin in Full ON mode which shows mobile site to mob users and normal site to others. Is that correct?

    I actually want to show a mob site to mobile users but don’t want to cache those pages, as those visits are extremely less in number compared to normal web visits.

  9. @Sriraj: The plugin now inserts mod_rewrite rules to handle requests for mobile clients so it can run in full “ON” mode now. It excludes those clients from receiving static files.

    You could set the “don’t cache for known users” option.

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close