Multiple blocks or single reg exp

which would be the best way to handle this multiple location blocks or a
single location block with a regular exp.

location /css/ { root /var/www/static_includes/; expires 97d; }
location /images/ { root /var/www/static_includes/; expires 97d; }
location /js/ { root /var/www/static_includes/; expires 97d;}

location ~ /(css|images|js)/ {
root /var/www/static_includes/;
expires 97d;


Posted at Nginx Forum:,213142,213142#msg-213142


On Sun, Jul 31, 2011 at 09:27:41AM -0400, token wrote:

location ~ /(css|images|js)/ {
root /var/www/static_includes/;
expires 97d;

Use multiple normal location blocks.

Regexp locations do introduce unneeded complexity and make
configuration maintenance much harder. Besides that, (a) it’s
easy to make regexp incorrectly (e.g. you missed “^”) and (b)
normal locations are faster (though you wouldn’t likely notice).

Maxim D.

Thanks for pointing that out. Locations it is then Thanks again Maxim!

Posted at Nginx Forum:,213142,213145#msg-213145