I’ve previously written about how to configure WP Super Cache to work with Nginx.
When using a mobile theme plugin, WPtouch in my case, the serving of static files (WP Super Cache does that in rewrite mode) needs to be disabled for mobile requests. Otherwise you could end up with static files (containing your standard theme) being served to mobile users.
WP Super Cache also needs to be configured with Mobile device support to prevent mobile visitors from trigger static files to be generated. So start by enable that feature in the advanced settings for WP Super Cache.
![]()
Then change the Nginx rewrite rules to the following.
# Return existing files
if (-f $request_filename) {
break;
}
set $supercache_file '';
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri '';
}
# Bypass cache for requests containing a query string
if ($query_string) {
set $supercache_uri '';
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}
# Bypass cache for mobile users
if ($http_user_agent ~* "(Android|CUPCAKE|bada|blackberry 9800|blackberry9500|blackberry9520|blackberry9530|blackberry9550|dream|iPhone|iPod|incognito|s8000|webOS|webmate)") {
set $supercache_uri '';
}
# Specify the cache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}
# Serve the cache file, if it exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
# Everything else goes to index.php
if (!-e $request_filename) {
rewrite . /index.php last;
}
The user agents listed above are the same ones WPtouch sends the mobile theme to. If you change the settings in WPtouch, change the rewrite rules as well.
Reload Nginx.
Install, enable and configure the WPtouch plugin, and that should be it. I’ve been using this setup for about a month now without any problems, let me know if you run into something.

