echo_reset_timer

The `echo_reset_timer` directive resets the elapsed time tracking for subsequent echo commands in NGINX.

Syntaxecho_reset_timer;
Defaultnone
Contextlocation, if in location
Argumentsnone

Description

The echo_reset_timer directive is part of the NGINX Echo module, which allows for advanced control over request processing and response generation. When this directive is called within a location block, it initiates a reset of the timer that measures the duration taken by subsequent commands such as echo or echo_sleep. By invoking echo_reset_timer, the total elapsed time for commands following this directive is treated independently of any previous commands, allowing for more precise measurements of response times for specific outputs without the interference of earlier commands.

This directive operates in specific contexts: it can be used within a location block or inside an if condition within a location block. Notably, echo_reset_timer does not accept any arguments, making it straightforward to implement in an NGINX configuration. The directive is especially useful in scenarios where accurate timing of different segments of response generation is required, enabling developers to optimize the overall performance of their NGINX applications effectively.

Config Example

location /timed_hello {
    echo_reset_timer;
    echo hello world;
    echo "'hello world' takes about $echo_timer_elapsed sec.";
    echo hiya igor;
    echo "'hiya igor' takes about $echo_timer_elapsed sec.";
}

Make sure to understand the timing context when using this directive, as intervals can be reset multiple times during a request.

This directive has no effect if not followed by subsequent echo commands; it simply resets the timer for the next commands executed afterward.

← Back to all directives