Var: Fix cacheable issue for njs variable access

The variables accessed with JS template literal should not be cacheable.
Since it is parsed by njs engine, Unit can't create indexes on these
variables for caching purpose. For example:

   {
       "format": "`{bodyLength:\"${vars.body_bytes_sent}\",status:\"${vars.status}\"}\n`"
   }

The variables like the above are not cacheable.

Closes: https://github.com/nginx/unit/issues/1169
This commit is contained in:
Zhidao HONG
2024-03-06 16:09:32 +08:00
committed by Andrei Zeliankou
parent 97ff09903b
commit 6359c74da1

View File

@@ -147,7 +147,7 @@ nxt_var_ref_get(nxt_tstr_state_t *state, nxt_str_t *name, nxt_mp_t *mp)
if (decl != NULL) { if (decl != NULL) {
ref->handler = decl->handler; ref->handler = decl->handler;
ref->cacheable = decl->cacheable; ref->cacheable = (mp == state->pool) ? decl->cacheable : 0;
goto done; goto done;
} }