WPtouch and WP Super Cache
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.
23 Comments
-
1 year, 2 months
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 ;)
-
1 year, 1 month
Everything seems to be working with the fixes but how do you get the plugin to work again after clicking on the “view normal” ?
-
1 year, 1 month
This worked for me after I cleared the cache. Thanks for a great plugin!
-
1 year, 1 month
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.
-
1 year, 1 month
@KirklandViews did you also add the user agent strings to the WP-Super Cache adminstration panel?
-
1 year, 1 month
Awesome plug-in!!
I did as you suggested above and seems to be working fine :-)
Cheers. -
1 year
It’s working fine for me
Thank you very mmuch
-
12 months
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?
-
12 months
Do these changes still apply when using 1.8.1 with Android and experimental Blackberry Storm support?
-
12 months
The best way I have found to test it in the browser is to use Safari and change the user agent or use Firefox with the UserAgent Switcher extension and switch it to iphone.
-
11 months, 3 weeks
Yeah! It’s working fine for me too!
-
11 months, 3 weeks
The above rule only covers iPhone. To allow support for all mobile devices that WPtouch supports you need to add this line instead:
RewriteCond %{HTTP_USER_AGENT} !^.+(iPhone|iPod|aspen|dream|incognito|webmate|BlackBerry9500|BlackBerry9530)
Please note that this list came directly from WPtouch.php ver 1.8.4. You should also add ALL of these devices to the list of rejected user agents in the WP Super Cache admin.
-
11 months, 1 week
Yeah, working for me too. Note that I have excluded the full list of user agents but was only able to test iPhone. Thanks!
-
11 months, 1 week
Thanks for this tip- am running Super Cache and seeing everything correctly on iPhone.
-
10 months, 4 weeks
thankz for info. i just try this plugin :)
-
10 months, 2 weeks
My website does not work with internet explorer if i activate supercache and WPtouch?? How come??
I even tried only with supercache and WPtouch plugin activated only, and still the same problem, i did as described above and my site loads great on iPhone, Firefox, Google Chrome and so on, but not on internet explorer, what can be the problem in this case?
-
10 months
Putting this in as a rule in my htaccess file lead to 404 pages:
RewriteCond %{HTTP_USER_AGENT} !^.+(iPhone|iPod|aspen|dream|incognito|webmate|BlackBerry9500|BlackBerry9530)
-
1 month, 1 week
Is this mod still required in some fashion? Latest version of supercase includes ‘iphone’ in its list already.
-
1 week, 6 days
Seems it works for me!
Thanks!