All Collections
Raidboxes Features
Cache
Cache: Create your own caching rules
Cache: Create your own caching rules

The Raidboxes cache allows you to create your own caching rules and determine which content should or should not be cached.

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

The Raidboxes cache temporarily stores all static content and delivers it at lightning speed when your page is visited - even if your website is not yet in the browser cache.

Advanced custom caching rules allow you to control exactly which content should be cached or not. This means you can, for example, make non-cacheable content cacheable and exclude content from caching that would usually be cached automatically.

Caution: If you add a caching rule or exception, this rule can overwrite every other caching rule on your Box or ones specific to WooCommerce. An additional rule may cause your website to stop working correctly. If you're not exactly sure what your caching rule should look like, make sure you test it in a Demo Box first. How to clone your live site into a new Demo Box is described here: Clone a Box.



How our caching rules work

You can create as many caching rules as you like in the cache settings. They will be applied in descending order from top to bottom. This means the uppermost caching rule will be applied first, followed by the second caching rule in the list and so on. 

Important: If a caching rule further down the list overrides a caching rule higher up the list, then the lower caching rule always applies.

Caching Rules - Moving Rules

Use the arrow symbols in the upper left corner of your caching rule list to move a caching rule up or down and thus change the order in which the rules are applied.

Tip: Take a look at our standard caching rules before you add any additional caching rules. These standard rules are active on all Boxes by default and do not need to be set individually.

How to add a new caching rule

Click on Add new rule. A form will open where you can define the new caching rule.

Caching rule components and logic

A caching rule always consists of five elements:

1. Name

Every caching rule needs a unique name or title. This is the only way to distinguish the rules from each other and ensure they are applied in the correct order. This title will appear in your site's response header as x-cache-skip-reason - provided of course they trigger an uncached request.

2. Type

The type is the most important element of a caching rule. It defines whether the caching rule is based on a URL, a cookie or a URL parameter. You can choose from the following types:

  • Site URL: This type allows you to create caching rules based on specific URLs. For example, you can specify that the URL raidboxes.io/tarife should not be cached. The field for a Site URL should only ever contain the path of a respective page and never the full URL. This means for raidboxes.io/tarife you would only enter /tarife in the value field next to type.

  • Query string: With this type you can define a query string that may or may not be cached. If you don't know what a query string is and how they work on your site, we recommend you ask your developer or web designer to set this caching rule for you.

Important: Caching rules based on query strings are only applied if they match exactly. Any missing or additional characters in the query string will not trigger the caching rule.

  • Cookie: Cookies can also be used as a type. If you enable a caching rule with this option, it will apply to all requests from clients where the corresponding cookie is stored.

Info: Our staging environment works in this way. Whenever the Raidboxes staging cookie is set, the page is delivered uncached. The difference is that you cannot override this caching rule and so your staging environment will always be delivered uncached.

  • Argument: This type works in a similar way to the query string type except that you define a single parameter and not a complete query string. The caching rule is thus triggered by every URL in which the parameter you define occurs, regardless of whether other parameters are set in the URL.

Example: The URL raidboxes.io/blog?raid=boxes&foo=bar is requested. If you have set a caching rule with the argument "raid" and the value "boxes", then the request will trigger the rule. A rule based on a query string will only be triggered if it exactly matches raid=boxes&foo=bar. A query string rule that is only raid=boxes or foo=bar will not be triggered.

3. Value

The value specifies the selected type of caching rule, i.e. gives a value to the type. If you selected Site URL as the type, for example, the value describes the concrete URL extension for which the caching rule should apply. This could be, e.g. /tarife.

For the type Cookies, the value is the name of the cookie, and for Query strings, the value is the complete query string that should be used to trigger the rule. You need to specify two values for argument types: (1) the name of the argument and (2) the value of the argument that will be used as the trigger. The name of the argument could be, for example, raid and the value boxes.

4. Cache

This option determines exactly what should happen when the conditions of the rule are met. Should the content of the site URL be cached or not? Should the page never or always be cached for users with a specific cookie?

5. Regex

Just like with redirects, you can also work with regular expressions for caching rules. You simply need to switch the Regex option on by selecting enabled or enabled (case insensitive) in the dropdown. If you know don't what regular expressions are or how they work, it's best to ask your web designer to set the appropriate caching rule for you.

Tip: The website regex101.com offers a free and comprehensive regex check with a handy overview of many syntax elements of regular expressions.

How to save and apply a caching rule

When you are finished entering the elements in the appropriate fields, you need to click first on Save to save your caching rule and then Apply rules. It is important to click on both of these otherwise the rule will not be applied correctly. If you only save a rule without applying it, it will not be active on your site.

Caching Rules - Saving Rules

Note: If you make changes to a rule, it also needs to be saved before it can be applied later on.

Please note that it may take 5-10 minutes for the rule to be fully applied.

Did this answer your question?