One request we hear over and over from the users of WPtouch is for WPtouch to somehow be able to work along side the WP Super Cache plugin. WPtouch has always been able to work when WP Super Cache is in half-on mode (which basically makes it the equivalent of the WP Cache plugin), and where the word “iPhone” is added to the list of rejected user agent strings. Unfortunately, it’s never quite worked properly when WP Super Cache is in full-on mode.
Running WP Super Cache in full-on mode actually bypasses WordPress in a lot of cases, and serves a cached version of the web page instead. This leads to problems with WPtouch and inconsistent behaviour, since sometimes a cache file from the normal web version is shown to a WPtouch user.
There are a few different ways to address this problem, and we might take a stab at adding an option in the WPtouch back-end at some point to help deal with this. A temporary solution (in theory) is to add this line to your .htaccess file in the two sections where WP Super Cache modifies it:
RewriteCond %{HTTP_USER_AGENT} !^.+iPhone
You can see a full example here:
# BEGIN WPSuperCache
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.+(iPhone|iPod|aspen|dream|android|BlackBerry9500|BlackBerry9530)RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.+iPhone
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
# END WPSuperCache
This should cause the Super Cache portion of WP Super Cache to bypass the static cached files whenever it is accessed by an iPhone. You will still need to add the iPhone word to the list of rejected user agents in the WP Super Cache admin.
If you have success with this method, please let us know as we’ve only done limited testing with it.
25 Comments
Steven
http://www.stevenhaddox.com
Made the suggested changes and it seems to work on my individual posts, but not on my actual homepage. Does WPtouch do anything to the homepage (I’ve just barely installed it so I’m not sure if it is supposed to off-hand, I would assume so). Other than the homepage though it seems to be working fine from both the browser and the iPhone ;)
Dale Mugford
BNC Design Guru
Did you clear your cache (in the admin, in your browser, and on the iphone/ipod touch)?
oneighturbo
http://www.oneighturbo.com
Everything seems to be working with the fixes but how do you get the plugin to work again after clicking on the “view normal” ?
Dale Mugford
BNC Design Guru
It should automatically insert footer links into your regular theme that allow for switching back to WPtouch. If they’re not there, you’re likely missing WordPress code in your footer.
Visit the WPtouch page and read up on the ‘Template Switch Code’ section of the documentation.
James
http://www.fcptutorials.com
This worked for me after I cleared the cache. Thanks for a great plugin!
KirklandViews
http://KirklandViews.com
This is not working for me. I love this plugin. I thought it was working fine, which it was briefly, but then when I cleared my iPhone cache, it has never returned. My iPhone must have loaded the WPtouch page before Super Cache was on. :-(
Now I am left with it not working.
Any work arounds would be greatly appreciated!
Thanks.
Duane Storey
BNC Development Guru
@KirklandViews did you also add the user agent strings to the WP-Super Cache adminstration panel?
Steve Cloke
Awesome plug-in!!
I did as you suggested above and seems to be working fine :-)
Cheers.
Peter
http://www.doomoney.com
It’s working fine for me
Thank you very mmuch
phototristan
http://tristantom.com
This seems to work fine for me!
I have a question though-is there a direct URL to the mobile site? (Like if I want to check it out on my regular desktop)? If so, what is the link address?
Studio Menu
More In Blog
Popular Website Places
BraveNewCode Online
All content Copyright © 2008 - 2012 BraveNewCode Inc.
Contact Us • Support Forums • Terms & Conditions • Built on fresh WordPress