[Patch] type{} directive

Grzegorz Nosek grzegorz.nosek at gmail.com
Wed Aug 18 18:51:07 MSD 2010


On Wed, Aug 18, 2010 at 04:19:08PM +0200, Grzegorz Nosek wrote:
> Hi all,
> 
> After a recent discussion I decided to whip up a patch implementing the
> type {} directive to route requests according to MIME types of requested
> files.
> 
> The main advantage is a clearer config file, as instead of:
> 
> | location ~ \.(gif|png|jpe?g|tif|ico) {
> |     expires max;
> |     access_log off;
> | }
> 
> you can now say:
> 
> | type image/* {
> |     expires max;
> |     access_log off;
> | }

I forgot to say that the type{} directive works inside location{} blocks
too:

| location /dev/ {
|     root /www/dev;
| 
|     type text/* {
|         expires epoch;
|     }
| }
| 
| location /prod/ {
|     root /www/prod;
| 
|     type text/* {
|         expires max;
|     }
| }

Although if you put a text{} block inside a location{}, this location no
longer interprets e.g. server{}-level types. We'll see if this is a
problem by popular demand :)

Best regards,
 Grzegorz Nosek



More information about the nginx mailing list