Cache: Standard rules

Some standard caching rules are set for each Box by default. Information on rules for advanced users.

Jan Hornung avatar
Written by Jan Hornung
Updated over a week ago

In addition to the flexible caching rules you can create for each of your Boxes individually, there are a number of default caching rules we set for each Box by default.

These rules are either required by WordPress, our system or for certain features to work. The second section of this article contains a set of rules specific to WooCommerce.

Important: Caching rules can overwrite our standard ruleset. It's therefore important to understand exactly what happens when you create a new caching rule or delete an existing one.



System caching rules

These rules are needed by Raidboxes or WordPress.

Please note: The information below is intended for experienced developers. An explanation of the caching rules can be found lower down in this article.

if ($request_method = POST) {

    set $skip_cache 1;

    set $skip_cache_reason "POST REQUEST";

}

if ($query_string != "") {

    set $skip_cache 1;

    set $skip_cache_reason "QUERY STRING";

}

if ($query_string ~* "^(&?(utm_(source|campaign|medium|term|content)|lang)=[A-Za-z0-9-._~:#@!$’()*+,;%]+)+") {

    set $skip_cache 0;

    set $skip_cache_reason "";

}

if ($query_string ~* "^relatedposts=1$") {

    set $skip_cache 0;

    set $skip_cache_reason "";

}

if ($request_uri ~* "(^/wp-admin/(.*)|(.*)wp-[A-Za-z0-9-._~:#@!$’()*+,;%]+.php|^/xmlrpc.php|(.*)(/)?index.php|(.*)sitemap(.*).xml)(\\?.*)?$") {

    set $skip_cache 1;

    set $skip_cache_reason "WORDPRESS URL";

}

if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {

    set $skip_cache 1;

    set $skip_cache_reason "WORDPRESS LOGGED IN";
}

Caching: WordPress text version

  • POST requests: POST requests never get cached.

  • Query strings: URLs that have query strings in them never get cached.

  • UTM parameters: an exception to the "query strings" rule above. URLs with UTM parameters will be cached normally.

  • Related posts: another exception to the "Query Strings" rule. If the URL is followed by the relatedposts=1 query string, the request will be cached normally.

  • WordPress URL: requests to wp-admin, PHP files of the WordPress core, xmlrpc.php, index-php, and the sitemap will never be cached. 

  • WordPress logged in: requests sent by a logged-in WordPress user will also never cached.

Cache and staging

Requests in the staging environment are always delivered uncached. This means the Raidboxes cache is always deactivated in the staging environment. If you have a cache plugin active on your WordPress site, deactivate it in the staging environment.

Rules specific to WooCommerce

Besides the system-specific caching rules explained above, there are several rules that ensure the correct caching of WooCommerce shops.

These rules are always active, even when WooCommerce is not actively in use. You can delete these rules if you do not use WooCommerce.

Caution: If you want to use WooCommerce at a later stage, your shop will need these rules again to work properly.

The existence or number of caching rules does not affect:

  • the page loading speed,

  • the Google ranking,

  • or the security of your website.

We set the following rules by default:

if ($request_uri ~* "^/(shop|cart|my-account|checkout|lost-password|addons|wc-api)(/(.*))?$") {

    set $skip_cache 1;

    set $skip_cache_reason "WOOCOMMERCE URL";

}

if ($arg_add-to-cart != "") {

    set $skip_cache 1;

    set $skip_cache_reason "WOOCOMMERCE ADD TO CART";

}

if ($arg_wc-api != "") {

    set $skip_cache 1;

    set $skip_cache_reason "WOOCOMMERCE API";

}

if ($http_cookie ~* "woocommerce_items_in_cart") {

    set $skip_cache 1;

    set $skip_cache_reason "WOOCOMMMERCE ITEMS IN CART COOKIE";

}

if ($http_cookie ~* "wp_woocommerce_session") {

    set $skip_cache 1;

    set $skip_cache_reason "WOOCOMMMERCE SESSION COOKIE";

}

if ($request_uri ~* "^/(warenkorb|einkaufswagen|mein-konto|kasse)(/(.*))?$") {

    set $skip_cache 1;

    set $skip_cache_reason "WOOCOMMERCE URL";

}

Caching: WooCommerce text version

  • WooCommerce URL: certain URLs within a WooCommerce shop should never be cached. This includes your cart, login area and forgot password function.

  • Add to cart: all requests that add products to your shop's cart will never be cached.

  • WooCommerce API: requests pointing to the WooCommerce API will never get cached.

  • Items in cart: If the cookie is set indicating a cart filled with products, user requests are never cached.

  • WooCommerce session cookie: WooCommerce uses session cookies to identify certain kinds of users. If a user triggers a request and has the WooCommerce session cookie in their browser, their request will not get cached.

  • German WooCommerce rule: ensures that German-language checkout areas, including the cart, are always loaded uncached and the shop functions correctly. WooCommerce only considers English-language URLs by default.

Did this answer your question?