1

https://codex.wordpress.org/Nginx#Nginx_fastcgi_cache currently has the following regex:

# 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 $no_cache 1;
}   
  1. I know Nginx doesn't require escaping forward slashes, but don't the periods need to be escaped?

  2. Shouldn't it be /wp-admin/.*? Otherwise most of the wp-admin urls can be cached. I know this is also taken care of with the "don't cache users with cookies" rule, but sometimes people setup weird wp-admin urls that can be hit without being logged in.

  3. If Wordpress is installed within a subdirectory, does it need the subdirectory at the front of the regex?

This is what I'm thinking it should be, but wanted to doublecheck here before updating the Codex:

# Don't cache uris containing the following segments
if ($request_uri ~* "/wordpress_subdirectory_if_any/(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 $no_cache 1;
}   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.