Skip to content

Instantly share code, notes, and snippets.

@dannysheehan
Created July 9, 2014 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannysheehan/ab98f0d2f9dfc3496802 to your computer and use it in GitHub Desktop.
Save dannysheehan/ab98f0d2f9dfc3496802 to your computer and use it in GitHub Desktop.
/etc/nginx/common/wpffpc.conf - recommended nginx memcached ffpc caching wordpress plugin
# http://centminmod.com/nginx_configure_wordpress_ffpc_plugin.html#220813
# try to get result from memcached
location @memcached {
default_type text/html;
set $memcached_key data-$real_scheme://$host$request_uri;
set $memcached_request 1;
# exceptions
# avoid cache serve of POST requests
if ($request_method = POST ) {
set $memcached_request 0;
}
# avoid cache serve of urls with a query string.
if ($query_string != "") {
set $memcached_request 0;
}
# Don't Cache Uris Containing The Following Segments
if ($request_uri ~* "(/wp-admin/|/forums/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $memcached_request 0;
}
# Don't Use The Cache For Logged In Users Or Recent Commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $memcached_request 0;
}
if ( $memcached_request = 1) {
add_header X-Cache-Engine "WP-FFPC with memcached via nginx";
memcached_pass memcached-servers;
error_page 404 = @rewrites;
}
if ( $memcached_request = 0) {
rewrite ^ /index.php?q=$request_uri last;
#rewrite ^ /index.php last;
}
}
## rewrite rules
location @rewrites {
add_header X-Cache-Engine "";
rewrite ^ /index.php?q=$request_uri last;
#rewrite ^ /index.php last;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment