Mercurial > hg > nginx-site
comparison xml/en/docs/njs/reference.xml @ 2926:237a77d8565b
Extended description of r_variables in njs.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Thu, 05 Jan 2023 16:34:01 +0000 |
parents | 3be061a0941a |
children | 16613b91c584 |
comparison
equal
deleted
inserted
replaced
2925:3be061a0941a | 2926:237a77d8565b |
---|---|
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> | 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
8 | 8 |
9 <article name="Reference" | 9 <article name="Reference" |
10 link="/en/docs/njs/reference.html" | 10 link="/en/docs/njs/reference.html" |
11 lang="en" | 11 lang="en" |
12 rev="94"> | 12 rev="95"> |
13 | 13 |
14 <section id="summary"> | 14 <section id="summary"> |
15 | 15 |
16 <para> | 16 <para> |
17 <link doc="index.xml">njs</link> provides objects, methods and properties | 17 <link doc="index.xml">njs</link> provides objects, methods and properties |
576 <tag-desc> | 576 <tag-desc> |
577 <link doc="../varindex.xml">nginx variables</link> object, writable | 577 <link doc="../varindex.xml">nginx variables</link> object, writable |
578 (since <link doc="changes.xml" id="njs0.2.8">0.2.8</link>). | 578 (since <link doc="changes.xml" id="njs0.2.8">0.2.8</link>). |
579 | 579 |
580 <para> | 580 <para> |
581 For example, to get the <literal>$foo</literal> variable, | |
582 one of the following syntax can be used: | |
583 <example> | |
584 r.variables['foo'] | |
585 r.variables.foo | |
586 </example> | |
587 nginx treats variables referenced in <literal>nginx.conf</literal> | |
588 and unreferenced variables differently. | |
589 When a variable is referenced, it may be cacheable, | |
590 but when it is unreferenced it is always uncacheable. | |
591 For example, when the | |
592 <link doc="../http/ngx_http_core_module.xml" id="var_request_id">$request_id</link> | |
593 variable is only accessed from njs, | |
594 it has a new value every time it is evaluated. | |
595 But, when the | |
596 <link doc="../http/ngx_http_core_module.xml" id="var_request_id">$request_id</link> | |
597 is referenced, for example: | |
598 <example> | |
599 proxy_set_header X-Request-Id $request_id; | |
600 </example> | |
601 the <literal>r.variables.request_id</literal> returns the same value every time. | |
602 </para> | |
603 | |
604 <para> | |
581 A variable is writable if: | 605 A variable is writable if: |
582 <list type="bullet"> | 606 <list type="bullet"> |
583 | 607 |
584 <listitem> | 608 <listitem> |
585 it was created using the <literal>js_var</literal> directive for | 609 it was created using the <literal>js_var</literal> directive for |