Welcome! Log In Create A New Profile

Advanced

Re: Performance question regarding regex

July 16, 2010 05:32AM
On Thu, Jul 15, 2010 at 09:18:33PM -0400, panni wrote:

> Dear forums/mailing list,
>
> just a quick question:
>
> [code]location / {
> root /home/folder/www;
> index index.php;
> #if (!-e $request_filename) {
> if ($request_filename !~*
> ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$)
> {
> #rewrite ^(.*)$ /index.php?q=$1 last;
> rewrite ^.*$ /index.php last;
> break;
> }
> root /home/folder/www;
> expires 30d;
> break;
> }
>
> [/code]
>
> What would be faster here. Using the commented "#if (!-e
> $request_filename) {" or the explicit filetype matching?

The better will be

root /home/folder/www;

location / {
index index.php;
fastcgi_pass ...
fastcgi_param SCRIPT_FILENAME /home/folder/www/index.php;
include fastcgi_params;
}

location ~* \.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$ {
expires 30d;
}

or

root /home/folder/www;

location / {
try_files $uri $uri/ @php;
index index.php;
expires 30d;
}

location \.php$ {
fastcgi_pass ...
fastcgi_param SCRIPT_FILENAME /home/folder/www$uri;
include fastcgi_params;
}

location @php {
fastcgi_pass ...
fastcgi_param SCRIPT_FILENAME /home/folder/www/index.php;
include fastcgi_params;
}


--
Igor Sysoev
http://sysoev.ru/en/

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

Performance question regarding regex

panni July 15, 2010 09:18PM

Re: Performance question regarding regex

panni July 15, 2010 09:24PM

Re: Performance question regarding regex

Igor Sysoev July 16, 2010 05:32AM

Re: Performance question regarding regex

panni July 29, 2010 07:44PM

Re: Performance question regarding regex

Igor Sysoev July 30, 2010 03:10AM

Re: Performance question regarding regex

panni July 30, 2010 09:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 270
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready