view xml/en/docs/faq/variables_in_config.xml @ 196:aafe530e7d6f

- Added faq/ and more q&a as previously agreed
author Andrey Alexeev <andrew@nginx.com>
date Wed, 23 Nov 2011 15:32:04 +0000
parents
children ec4626d04879
line wrap: on
line source

<!DOCTYPE article SYSTEM "../../../dtd/article.dtd">

<article name="Is there a proper way to use nginx variables to
               make sections of the configuration shorter,
               using them as macros for making
               parts of configuration work as templates?"
         link="/en/docs/faq/variables_in_config.html"
         lang="en">

<section>

<para>
<initial>Q:</initial>
Is there a proper way to use nginx variables to make sections of
the configuration shorter, using them as macros for making
parts of configuration work as templates?
</para>

<para>
&nbsp;
</para>

<para>
<initial>A:</initial>
Variables should not be used as template macros. Variables are
evaluated in the run-time during the processing of each
request, so they are rather costly compared to plain static
configuration. Using variables to store static strings is also
a bad idea. Instead, a macro expansion should be used to
generate configs more easily and it can be done with the
external tools, e.g. sed + make or any other common template
mechanism.
</para>

</section>

</article>