Chris, thank you, this is what i need.
By the way, i found one strange thing - operator "if" don't work with $upstream_cache_status.
For example, i try to change "HIT" and "MISS" to more enigmatic values
set $tocache X;
if ($upstream_cache_status = HIT)
{
set $tocache H;
}
if ($upstream_cache_status = MISS)
{
set $tocache M;
}
add_header tocache "$tocache ($upstream_cache_status)";
I expected to see "tocache: M (MISS)" and "tocache: H (HIT)".
But i got "tocache: X (MISS)" and "tocache: X (HIT)".
Maybe "if" works not for any variable?