nginx.confの変数は読みやすさのために使うな。

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?

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 and “include” directives 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.

意訳:リクエストの度に余計な負荷が掛かるから、変数使わないでベタに書け。読みやすくしたいなら他の方法を使え。

capistrano-puma/puma.rake at master · seuros/capistrano-puma

upload! StringIO.new(ERB.new(erb, nil, ‘-‘).result(binding)), to

ということで、同じ時期に触ってたcapistrano-pumaが同じようなことでerb使ってたのでマネしました。

タイトルとURLをコピーしました