img-1

Setting up Page Rules to tune the performance

By creating a “Page Rule” you can control the performance behavior for pages of your website. Page Rules help you to configure optimization features for different sections of your website based on what is best for that segment, for example, public-facing pages and admin panel. The rule is applied based on the URL pattern you define for your rule.

Page rule helps website owners to control many features such as image conversion to WebP, lazy loading of images, defer ads and analytics, HTML, CSS, and JS code modification, etc.

Create a new rule

You can navigate to Settings -> Page Rules -> Add new rule.

img-2

URL pattern

A URL pattern (for example, blog/*) specifies which requests you want this page rule to apply to. When RabbitLoader receives a pageview request from a visitor, the requested URL is compared and matched with URL patterns in the order in which page rules are listed. The first match determines which rule and optimization are applied to that request.

For example, if a visitor is loading a page at URL https://website.com/blog/2023/some-slug/ and let’s say there are two rules, first with a with URL pattern blog/* and second one with URL pattern just a (*). For this URL both rules are matching and the settings provided in the first match will be used for this page optimization.

You can use the following wildcard characters in your path pattern:

  • ? matches exactly 1 character.
  • * matches 0 or more characters.

Content-type

Content type decides how the page should be cached and served to different users. It can be one of these-

Static content

The content served is the same for everyone. It is not based on cookies or sessions. In this case, RabbitLoader allows you to optimize and cache the content at CDN to boost the speed. Blog articles or the home page are the perfect examples. This can give you the best speed. Choose this section if the static assets such as JavaScript, CSS, images, font files, etc are served from a directory matching this rule.

Semi-dynamic

The content is different for users based on their session or cookies. For example, a product page on your e-commerce site (or WooCommerce or a similar plugin) is almost the same for everyone but shows cart item count/value on the same page based on the user session. In this case, RabbitLoader allows you to optimize and cache the content (per session) at CDN to boost the speed. If the cart is updated from ajax, you may choose to keep the products pages under the “Static” category and the ajax path under the “Dynamic” category for best performance.

Full-dynamic

RabbitLoader will not do any optimizations or cache the content. Admin panels are the best example of this category.

Execution Sequence

When a new rule is added, an auto-increment sequence number is assigned to the rule. By default, the newly added rule has the highest sequence number and it appears last in the rules list.

When a URL is optimized, all rules are compared in ascending order of their ‘matching sequence number’ until a match is found. So a rule with sequence 0 will be compared first when a URL is optimized. If the rule matches, no further rules with higher sequence numbers will be evaluated for the URL. Following the same convention, the * wildcard rule should come at the last and it should have the highest sequence. Any specific rules should have a lower sequence number than the * one. The sequence number can be adjusted with the help of up and down arrow buttons on the rules screen.

WordPress Example

For a typical WordPress website, this is how the Page Rules should be arranged. This explains how rules for the admin panel, assets folder, and other pages should be defined.

img-3

More examples and use cases

  1. Rule to convert image to WebP format
  2. Control lazy loading of images
  3. Whitelist only your country to access the admin panel
  4. Control lazy loading of ads code like AdSense, AdThrive etc.
  5. Minify HTML, CSS and JavaScript code
  6. Toggle JavaScript optimization
  7. Setting very long/immutable caching for /static content directory.