Contents

Cache rules

About 8 minUpdated 2026-10-28

Cache rules decide what a node keeps locally and for how long. The more complete the rules, the fewer requests go to the origin.

Two modes

Each site's cache rules and origin request headers can be set to "By group" or "Custom":

  • By group: follows the chosen cache group. Groups are maintained by the administrator; switching group replaces the site's rules with that group's. Users pick their default group under Default Settings › Cache Policy, and new sites use it by default.
  • Custom: the site uses its own rule table. The current rules can also be saved as a new group so other sites can reuse them.

Writing the rule table

Rules match by file extension, directory or full path, take effect from top to bottom, and the whole table is saved together. Each rule can set:

  • Match type and value: extension, directory or full path, for example extension jpg, directory /static/.
  • Cache time: how long nodes keep it, in seconds, minutes, hours or days; there is also a browser cache time that tells the visitor's browser how long to keep it.
  • Ignore parameters: no, all parameters, or specific ones. When ignored, the same file with different ? parameters is treated as one cache entry.
Tip Write one long-cache rule by extension for static resources (images, scripts, styles). Do not cache dynamic pages or paths with login state or personalized content.

Raise the hit ratio

Check the request and byte hit ratios in Statistics. A low ratio usually has two causes:

  1. The origin sends "do not cache" headers (Cache-Control: no-cache and so on): choose to ignore the origin's cache headers in the rule, or have the origin change its headers.
  2. The same file is treated as different files because of different ? parameters: turn on ignore parameters for static resources.
Caution Ignoring the origin's cache headers makes nodes disregard headers such as Set-Cookie. Use it only on paths that surely have no personalized content.

After changing rules, old cached content only updates immediately after purge and prefetch.