Last active
December 30, 2015 21:19
-
-
Save nghuuphuoc/7886804 to your computer and use it in GitHub Desktop.
Nginx config for Wordpress Super Cache plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
set $supercache_file ''; | |
set $supercache_uri $request_uri; | |
if ($request_method = POST) { | |
set $supercache_uri ''; | |
} | |
# Using pretty permalinks, so bypass the cache for any query string | |
if ($query_string) { | |
set $supercache_uri ''; | |
} | |
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { | |
set $supercache_uri ''; | |
} | |
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { | |
set $supercache_uri ''; | |
} | |
# if we haven't bypassed the cache, specify our supercache file | |
# REMEMBER to set the cache dir writable | |
if ($supercache_uri ~ ^(.+)$) { | |
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html; | |
} | |
# only rewrite to the supercache file if it actually exists | |
if (-f $document_root$supercache_file) { | |
rewrite ^(.*)$ $supercache_file break; | |
} | |
// ... Other Wordpress rewrite rules come here ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment