To create and deploy a snippet you must define the following elements:
- Snippet rule: Contains a that will define for which requests the snippet will run.
How it works
For each incoming request, Cloudflare evaluates the expression of each snippet rule defined in the zone checking for a match based on the request properties. Snippets are defined for each zone.
A snippet can run on every request or only on certain requests, based on various criteria such as bot score, country of origin, or a cookie.
Multiple snippets may run on the same request if their rule expressions match. This means that you could have a snippet adding an HTTP header and another snippet rewriting the URL, and they would both run if their corresponding expression matches the incoming request. Each snippet receives the modified request from the previous snippet and applies new modifications to it.
For each snippet rule whose expression matches the incoming request, the corresponding snippet code will be scheduled for execution. Cloudflare will apply the following logic for each snippet rule:
If <rule_expression> evaluates to true, then schedule <snippet_code> for execution
After evaluating all snippet rules, Cloudflare will execute the code of all scheduled snippets, in the same order their rules matched.
Number of snippets
|Maximum execution time
|Maximum total package size
The execution order of Rules products is the following: