Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Var: Fix cacheable issue for njs variable access. #1176

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

hongzhidao
Copy link
Contributor

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

@hongzhidao
Copy link
Contributor Author

Hi @andrey-zelenkov,
Please add a missing test on it, thanks.

Copy link
Member

@ac000 ac000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variables accessed with JS template literal should be not cacheable.

Minor nit. s/should be not/should not be/

Other than that, sure.

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: nginx#1169
@hongzhidao hongzhidao merged commit f6899af into nginx:master Mar 8, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using vars multiple times in access_log.format does not work correctly with njs
2 participants