Customizing Page Cache Exclusions

By default, any POST request or URLs containing query string parameters bypass the page cache. Certain URL paths and cookies also bypass the page cache. If a cookie is present for a logged in WordPress user or a shopping cart for WooCommerce or Easy Digital Downloads for example, the page cache will be skipped. SpinupWP also excludes the following paths from being cached:

/wp-admin/
/wp-json/
/xmlrpc.php
/wp-.*.php
/feed/
index.php
sitemap(_index)?.xml
/cart/
/checkout/
/my-account/

Be aware that these default paths will exclude nested paths. For example, /my-account/settings/ and /my-account/orders/ will be excluded from the page cache.

While these default exclusions serve as a good starting point for most sites, you’re free to completely customize the cache exclusions.

Modifying Cache Exclusions

To customize the page cache exclusions, navigate to the Page Cache tab under a site and add the path you want to exclude from the page cache to a new line in the Path Exclusions text area.

Modify page cache exclusions

You’ll notice that it’s not currently possible to add cookies to the list of exclusions from the SpinupWP dashboard. For this, you’ll need to connect to the server as a sudo user via SSH and edit the following file:

sudo nano /etc/nginx/sites-available/{site-name}/server/fastcgi-cache.conf

Locate the following lines of code:

# 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|edd_items_in_cart|woocommerce_items_in_cart") {
        set $skip_cache 1;
}

You’ll notice the cookie names are separated by a pipe character. You can add a pipe character and the name of the cookie you’d like to add to the list.

Save the file, reload Nginx, and the cache should now be skipped that cookie is present.

Page Cache Headers

When the page cache is enabled in SpinupWP all responses will have the Fastcgi-Cache header present. This header can have 1 of 3 values:

MISS – The page is not cached but will be on subsequent requests
HIT – The page is cached
BYPASS – The page is excluded from the page cache

You can use these values to help debug page caching issues.