map to use regex or not

Reinis Rozitis r at roze.lv
Wed May 31 18:13:03 UTC 2017


Hello,
I have a setup where I need to override backend's content type and was wondering which approach (without too much digging into source and/or doing microbenchmarks) is better (less cpu) from performance point of view? 


map $uri $custom_content_type {
  hostnames;
   *.jpg "image/jpeg";
} 

or with regex

map $uri $custom_content_type {
  ~\.jpg$ "image/jpeg";
}


(in general just for theoretical knowledge since the difference as I imagine is most likely  very minimal/unnoticable)

rr



More information about the nginx mailing list