2.4.5 MIME类型的设置
下面是MIME类型的设置配置项。
❑MIME type与文件扩展的映射
语法:type{……};
配置块:http、server、location
定义MIME type到文件扩展名的映射。多个扩展名可以映射到同一个MIME type。例如:
types{
text/html html;
text/html conf;
image/gif gif;
image/jpeg jpg;
}
❑默认MIME type
语法:default_type MIME-type;
默认:default_type text/plain;
配置块:http、server、location
当找不到相应的MIME type与文件扩展名之间的映射时,使用默认的MIME type作为HTTP header中的Content-Type。
❑types_hash_bucket_size
语法:types_hash_bucket_size size;
默认:types_hash_bucket_size 32|64|128;
配置块:http、server、location
为了快速寻找到相应MIME type,Nginx使用散列表来存储MIME type与文件扩展名。types_hash_bucket_size设置了每个散列桶占用的内存大小。
❑types_hash_max_size
语法:types_hash_max_size size;
默认:types_hash_max_size 1024;
配置块:http、server、location
types_hash_max_size影响散列表的冲突率。types_hash_max_size越大,就会消耗更多的内存,但散列key的冲突率会降低,检索速度就更快。types_hash_max_size越小,消耗的内存就越小,但散列key的冲突率可能上升。