All Products
Search
Document Center

:How EdgeScript works

Last Updated:Mar 01, 2024

This topic describes how EdgeScript works. This topic also describes the execution model of scripts in EdgeScript, positions where the scripts are executed, script priorities, and execution and termination of scripts.

How it works

The scripts that you configure by using EdgeScript serve the same purpose as the standard configurations in the ApsaraVideo Live console. Both of them are used to process the requests for ApsaraVideo Live. The following figure shows the positions where the scripts are executed. After a client sends a request to a CDN point of presence (POP) of ApsaraVideo Live, the ApsaraVideo Live gateway processes the request based on the scripts or the standard configurations that you configure in the ApsaraVideo Live console. You can execute a script at the start or end of a request processing pipeline by using the standard configurations in the ApsaraVideo Live console as a reference.

image

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.

    image
  • 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 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.

  • 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.