Documentation Index
Fetch the complete documentation index at: https://docs.bunny.net/llms.txt
Use this file to discover all available pages before exploring further.
How Edge Rules Are Ordered
Edge Rules execute in the order defined by the OrderIndex. Rules are always processed from the smallest to the largest OrderIndex value:- A rule with
OrderIndex = 1will execute before a rule withOrderIndex = 2. - All rules are executed sequentially based on their index.
Default Behavior: What Happens if No OrderIndex Is Set?
If you do not specify an OrderIndex for your Edge Rules:
- Rules will execute in the order they were created.
Short-Circuiting vs. Multi-Action Execution
Edge rules process actions differently depending on the action type. Some actions follow a short-circuiting model, where only the first matching action of that type is executed, and further actions of that same type are ignored. This behavior applies when executing multiple actions of the same kind would cause conflicts or unintended side effects. Other actions support multi-action execution, meaning all matching actions of that type are processed, in sequence. This is typical for additive behaviors like setting response headers or appending cookies, where multiple values can coexist. We will add either the π(short-circuiting model) or π(multi-action execution) icon to the action list below to indicate how each action is processed.
Example Behaviors
If multiple rules modify the same request or response header, all matching actions will be executed, allowing cumulative changes. If multiple rules attempt to rewrite the URL or redirect, only the first matching action is executed, and subsequent conflicting actions are skipped. Example:| OrderIndex | Condition | Action |
|---|---|---|
| 1 | If Request URL equals /images | Override Browser Cache Time -> 3600 |
| 2 | if Request URL equals /images | SetResponseHeader -> hello=world |
| 3 | If Request Header -> User-Agent contains Googlebot | Override Browser Cache Time -> 5 |
| 4 | if Request Header -> User-Agent contains Google | SetResponseHeader -> hello2=world2 |
- The
Cache-Controlvalue will be3600, becauseOverride Browser Cache Timeis a π short-circuiting action and the first match (OrderIndex = 1) wins. - Both
SetResponseHeaderactions will execute, resulting inhelloandhello2headers being added.
Edge Rule Execution Layers (Cache vs Origin)
Edge Rules execute in two distinct stages of the request lifecycle:- Cache Layer - evaluated on every request, before cache lookup and cache decision are finalized
- Proxy (Origin) Layer - evaluated only if the request goes to origin (CACHE MISS or BYPASS)
Request Flow Overview
A request is processed in the following order:- Edge Rules (Cache Layer)
- Cache Lookup (HIT or MISS)
- Edge Rules (Proxy/Origin Layer, only on MISS/BYPASS)
- Origin Request (if needed)
Cache Layer Execution (Always Runs):
The following Edge Rules are evaluated at the Cache Layer, meaning they run on every request before cache resolution, regardless of whether the final result is a HIT or MISS.ForceSSL(Enum Value:0) πRedirect(Enum Value:1) πOverrideCacheTime(Enum Value:3) π Note: if set to0it will bypass edge cache, if we donβt already have the content cached on our edge.BlockRequest(Enum Value:4) πSetResponseHeader(Enum Value:5) πForceDownload(Enum Value:7) πDisableTokenAuthentication(Enum Value:8) πEnableTokenAuthentication( Enum Value:9) πOverrideCacheTimePublic(Enum Value:10) πIgnoreQueryString(Enum Value:11) πDisableOptimizer(Enum Value:12) πForceCompression(Enum Value:13) πSetStatusCode(Enum Value:14) πOverrideBrowserCacheTime(Enum Value:16) πSetNetworkRateLimit(Enum Value:18) πSetConnectionLimit(Enum Value:19) πSetRequestsPerSecondLimit(Enum Value:20) πOverrideBrowserCacheResponseHeader(Enum Value:25) πRemoveBrowserCacheResponseHeader(Enum Value:26) πDisableShieldChallenge(Enum Value:27) π
Proxy (Origin) Layer Execution (MISS/BYPASS Only):
The following Edge Rules are evaluated only when the request reaches the origin, meaning:- Cache MISS
- Cache BYPASS (e.g. due to rules or headers)
OriginUrl(Enum Value:2) πOverrideCacheTime(Enum Value:3) πSetResponseHeader(Enum Value:5) πSetRequestHeader(Enum Value:6) πBypassPermaCache(Enum Value:15) πOriginStorage(Enum Value:17) πRunEdgeScript(Enum Value:21) πOriginMagicContainers(Enum Value:22) πDisableWAF(Enum Value:23) πRetryOrigin(Enum Value:24) πDisableShieldChallenge(Enum Value:27) πDisableShieldBotDetection(Enum Value:29) πBypassAwsS3Authentication(Enum Value:30) π
Setting the Execution Order
Method 1: Dashboard (Drag & Drop)
You can reorder your Edge Rules visually:- Go to your Pull Zone > Edge Rules tab.
- Click βReorderβ badge at the top of the page.
- Drag rules to change their order.
- The order you set will automatically adjust the OrderIndex behind the scenes.
Method 2: API (Set OrderIndex Directly)
If you manage rules programmatically via our API, you can set the execution order by adjusting theOrderIndex value when creating or updating an edge rule.
Best Practices
- Plan rule priorities carefully, especially when multiple rules affect the same property or header.
- Keep related rules grouped and ordered for easier maintenance.
- Use the dashboard for visual management and the API for bulk or automated updates.