Gena Makhomed gmm at
Sat Jul 23 17:05:42 UTC 2011

On 23.07.2011 17:42, António P. P. Almeida wrote:

 >> +          location ^~ /media/ {
 >> +                # static
 >> +                expires 30d;
 >> +                error_page 404 = @joomla;
 >> +                log_not_found off;
 >> +          }

 > Wouldn't the use of try_files be preferable to error_page?
 > -                error_page 404 = @joomla;
 > +                try_files $uri $uri/ @joomla;

I just copy/paste/paste/paste already working config fragment...

 > From the little I know, try_files does a stat() call while error_page
 > is a special response. They both do an internal redirection. They run
 > on different phases. Is this correct? If so is there any rule of thumb
 > for deciding when to use try_files vs. error_page 404.

As far I know, "try_files $uri $uri/ @joomla;" directive
and "error_page 404 = @joomla;" with "log_not_found off;"

has the same behaviour, - this is written at russian documentation.

As I can see in
try_files first appeared in nginx 0.7.27, and last known bug
with try_files was fixed in nginx 0.8.39, so in older versions
of nginx error_page 404 with log_not_found off; may be better,
or may be the only one way to do such things.

and main purpose of try_files - is just to be syntactic sugar
for config files to be more clean and easy to read/understand.
as in C language a[i] notation is syntactic sugar for *(a + i)

Best regards,

More information about the nginx mailing list