Skip to content

Commit

Permalink
Var: Fix cacheable issue for njs variable access
Browse files Browse the repository at this point in the history
The variables accessed with JS template literal should be not 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: #1169
  • Loading branch information
hongzhidao committed Mar 6, 2024
1 parent c2f7f29 commit dd90a3b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nxt_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ nxt_var_ref_get(nxt_tstr_state_t *state, nxt_str_t *name, nxt_mp_t *mp)

if (decl != NULL) {
ref->handler = decl->handler;
ref->cacheable = decl->cacheable;
ref->cacheable = (mp == state->pool) ? decl->cacheable : 0;

goto done;
}
Expand Down

0 comments on commit dd90a3b

Please sign in to comment.