How EdgeScript works
This topic describes how EdgeScript (ES) works, the script model, positions where scripts are executed, script priorities, and execution and termination behavior.
How EdgeScript works
ES scripts are the same as the standard configurations in the ApsaraVideo VOD console to process requests sent to CDN points of presence (POPs). As shown in the following figure, after a CDN POP receives a request, it applies both the console configurations and ES scripts. You can position a script to run before the standard configurations take effect (head) or after (foot).

Model
Scripts in ES are executed based on the following model:
ES executes scripts to achieve different functions. Functions are triggered only when the conditions in scripts are met.
You can specify the position where a script is executed and the priority of the script in a request processing pipeline.
Scripts in ES are managed based on domain names.
Positions and priorities
The positions and priorities for executing scripts are:
Positions
You can execute a script at the head or foot of a request processing pipeline.
Head: for authentication, blocking, and throttling.
Foot: for cache settings, back-to-origin authentication, and A/B testing.

Priorities
If you want to execute more than one script at the head or foot of a request processing pipeline, you can assign priorities to these scripts to determine the execution order.
Execution and termination
The execution and termination of scripts are defined based on the following rules:
Execution of scripts
If the rule contains
if condition {}, andconditionis true, the rule model considers the rule as hit.If the rule contains
if condition {}, andconditionis false, or if the rule does not contain theif condition {}syntax, the rule model considers the rule as not hit.
Termination of scripts
For a rule that is hit, you can choose to terminate the execution of the remaining rules in the current phase.