Last active
June 30, 2017 09:07
-
-
Save ZE3kr/3c28029ffa4c91392045e9a579599646 to your computer and use it in GitHub Desktop.
Can be used for WP Super Cache plugin. You need to configure WP Super Cache to "Use PHP to serve cache files.", and turned ON "Don’t cache pages with GET parameters.", turned OFF "Compress pages so they’re served more quickly to visitors.".
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
# WP Super Cache rules. | |
# Designed to be included from a 'wordpress-ms-...' configuration file. | |
set $cache_uri $uri; | |
# POST requests and urls with a query string should always go to PHP | |
if ($request_method = POST) { | |
set $cache_uri 'null cache'; | |
} | |
# Disable cache for search pages | |
if ($request_uri ~ "^/\?s=") { | |
set $cache_uri 'null cache'; | |
} | |
# Disable cache for post pages, pleace use /%year%/%monthnum%/%postname%/ or others permalink settings instead of default settings. | |
if ($request_uri ~ "^/\?p=") { | |
set $cache_uri 'null cache'; | |
} | |
# Only cache URL's ending in / | |
if ($uri !~ /$) { | |
set $cache_uri 'null cache'; | |
} | |
# Don't cache uris containing the following segments | |
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 $cache_uri 'null cache'; | |
} | |
# Don't use the cache for logged in users or recent commenters | |
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") { | |
set $cache_uri 'null cache'; | |
} | |
location / { | |
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index-https.html /wp-content/cache/supercache/$http_host/$cache_uri $uri $uri/ /index.php?$args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment