This topic describes how EdgeScript (ES) works, the model of scripts in ES, positions where the scripts are executed, script priorities, and execution and termination of scripts.
How EdgeScript works
Scripts created by using ES are the same as the standard configurations specified in the CDN console. They process requests that are sent to CDN points of presence (POPs). The following figure shows the positions where scripts are executed. After a CDN POP receives a request, the POP processes the request based on the configurations in the Alibaba Cloud CDN console and scripts in ES. In a request processing pipeline, you can specify the position where a script is executed. A script can be executed before the configurations in the CDN console are applied (head) or after they are applied (foot).
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
- 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
- Execution of scripts
- If a condition that ends with
return true
in a script is met, the script is executed. - If a condition that ends with
return false
in a script is met, the script is skipped.
- If a condition that ends with
- Termination of scripts
For scripts that are executed in the same position, you can choose to skip the subsequent scripts when a script is executed.