Storing $server_addr in a variable VS using it directly in location block

According to the documentation getting the value of $server_addr to set
a
response header makes a system call, and can impact performance
negativelyset $ip $server_addr;

server {
    location /health {
        add_header Backend $server_addr;
        return 200;
    }
}

Would the following be a better solution, and eliminate the system call
on
every request?

server {
    set $ip $server_addr;

    location /health {
        add_header Backend $ip always;
        return 200;
    }
}

Posted at Nginx Forum:

On Tuesday 14 July 2015 21:46:58 justink101 wrote:

}

No, it wouldn’t. The “set” directive also is executed on every request.

wbr, Valentin V. Bartenev

Valentin V. Bartenev Wrote:

On Tuesday 14 July 2015 21:46:58 justink101 wrote:

According to the documentation getting the value of $server_addr to
set a
response header makes a system call, and can impact performance
negativelyset $ip $server_addr;

No, it wouldn’t. The “set” directive also is executed on every
request.

Via map as well ? (geo would suffer as well then)

Posted at Nginx Forum:

On Wednesday 15 July 2015 07:45:34 itpp2012 wrote:

Via map as well ? (geo would suffer as well then)

All variables work on a per requests basis, no exceptions.

wbr, Valentin V. Bartenev