# Good Directive vs Bad Directives

**URL:** <https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228>\
**Category:** NGINX\
**Created:** [April 24, 2012, 5:30pm UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228 "2012-04-24T17:30:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [April 24, 2012, 5:30pm UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/1 "2012-04-24T17:30:46Z")

</div>

Hello fellas,

I’ve read on [Pitfalls and Common Mistakes | NGINX](http://wiki.nginx.org/Pitfalls), what the different between  
bad  
and good? Any info related to this issue? Such as cpu load or mem load?

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [April 30, 2012, 11:27pm UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/2 "2012-04-30T23:27:44Z")

</div>

_bump_

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [May 1, 2012, 7:43pm UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/3 "2012-05-01T19:43:58Z")

</div>

On Tue, Apr 24, 2012 at 08:30:18AM -0700, antituhan wrote:

Hi there,

> I’ve read on [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/Pitfalls), what the different between bad  
> and good? Any info related to this issue? Such as cpu load or mem load?

The short version is: if you don’t understand them, just don’t do the  
bad ones.

The more useful information is:

that’s a wiki, so what I see when I read it now may not be what you saw  
when you read it. And it might be different tomorrow. And I’m not going  
to help the archaeologists by being explicit 😉

But reading that page right now, the first item seems described as a  
possible configuration maintainability problem; the second item seems  
the same – basically “don’t repeat what you don’t need to repeat”;  
the third item is described as processor-inefficient; the fourth item  
doesn’t say why but just says “use try\_files”.

Is any specific one unclear to you?

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [May 2, 2012, 3:35am UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/4 "2012-05-02T03:35:44Z")

</div>

Hi Francis, thanks for the response,

Ok, basicly it’s just a different directive (simple and ‘crowded’  
directive), isn’t it ? And it doesn’t matter with cpu/mem load (such as  
we  
simply could use “try\_files” than “if”). So, the conclusion is that “if”  
directive is same as “try\_files”, the different is only on the  
simplicity,  
and it’s not causing cpu/mem high load, right?

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [May 2, 2012, 3:47am UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/5 "2012-05-02T03:47:28Z")

</div>

On Tue, 2012-05-01 at 18:34 -0700, antituhan wrote:

> Hi Francis, thanks for the response,
> 
> Ok, basicly it’s just a different directive (simple and ‘crowded’  
> directive), isn’t it ? And it doesn’t matter with cpu/mem load (such as we  
> simply could use “try\_files” than “if”). So, the conclusion is that “if”  
> directive is same as “try\_files”, the different is only on the simplicity,  
> and it’s not causing cpu/mem high load, right?

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

Cliff

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [May 3, 2012, 3:04pm UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/6 "2012-05-03T15:04:35Z")

</div>

Ok thanks francis, got that point 🙂 If “try\_files” can do, we don’t  
need  
using “if”, and if “try\_files” can’t do, we just insert “if” directive  
(only  
if very needed). Isn’t it ?

Francis D. wrote

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [May 2, 2012, 1:38pm UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/7 "2012-05-02T13:38:23Z")

</div>

On Tue, May 01, 2012 at 06:34:57PM -0700, antituhan wrote:

Hi there,

> Ok, basicly it’s just a different directive (simple and ‘crowded’  
> directive), isn’t it ?

It’s a different directive, that does different things.

> So, the conclusion is that “if”  
> directive is same as “try\_files”, the different is only on the simplicity,  
> and it’s not causing cpu/mem high load, right?

“if” can do a lot more than try\_files, but has its own pitfalls when  
used within location{}.

If what you want is “if this file exists, process it; otherwise do this  
other thing”, that is what try\_files is for.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [May 4, 2012, 12:27am UTC](https://www.ruby-forum.com/t/good-directive-vs-bad-directives/219228/8 "2012-05-04T00:27:37Z")

</div>

On Thu, May 03, 2012 at 06:04:07AM -0700, antituhan wrote:

Hi there,

> Ok thanks francis, got that point 🙂 If “try\_files” can do, we don’t need  
> using “if”, and if “try\_files” can’t do, we just insert “if” directive (only  
> if very needed). Isn’t it ?

More or less, yes.

Use the right tool for the task. Sometimes try\_files is the right one,  
sometimes it isn’t.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
