Welcome! Log In Create A New Profile

Advanced

try_files

Gena Makhomed
July 23, 2011 01:06PM
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.
http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#try_files

As I can see in http://nginx.org/en/CHANGES
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,
Gena

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

try_files

Gena Makhomed July 23, 2011 01:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 52
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready