This topic describes the model of scripts in EdgeScript, positions where the scripts are executed, script priorities, execution and termination of scripts, and fields that each script contains.

Model

Scripts in EdgeScript are executed by using the following model:
  • EdgeScript executes scripts to achieve different functions. Functions are triggered 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 EdgeScript are managed by domain name.

Positions and priorities

The execution positions and priorities for executing scripts are as follows:
  • Positions
    You can execute a script at the start or end of a request processing pipeline.
    • Start: for authentication, blocking, or throttling.
    • End: for cache setting, back-to-origin authentication, and A/B testing.

    Positions
  • Priorities

    If you want to execute more than one script at the start or end 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 as follows:
  • Execution of scripts
    • If a condition ends with return true in a script is met, the script is executed.
    • If a condition 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.

Fields

A script contains the following fields:
Field Required Definition Description
enable Yes Enables or disables the script. Valid values:
  • on
  • off
pos Yes The position where the script is executed. Valid values:
  • head
  • foot
pri Yes The priority of the script. Valid values: from 0 to 999. Value 0 indicates the highest priority and value 999 indicates the lowest priority. You can only prioritize scripts that are executed in the same position.
rule Yes The content of the script. -
brk No Indicates whether to skip the subsequent scripts if the current script is executed. Valid values:
  • on
  • off
testip No The IP address of the client. By default, this field is empty. If you specify a client IP address, only requests sent from the specified IP address can trigger the execution of the script.
option No An extension. Currently, this field is supported. You can set this field to _es_dbg=signature to perform response header debugging.