concat_unique

The `concat_unique` directive controls whether only files of the same MIME type can be concatenated in NGINX.

Syntaxconcat_unique on | off;
Defaulton
Contexthttp, server, location
Argumentsflag

Description

The concat_unique directive, part of the HTTP Concatenation module in NGINX, is used to specify if concatenation of files is restricted to unique MIME types or if multiple MIME types can be concatenated together. By default, this directive is set to on, meaning that when users attempt to concatenate files through the specified syntax (e.g., ??file1.css,file2.css), only files of the same type, such as CSS or JavaScript, will be processed together. This restriction prevents potential issues with file processing that can arise from combining different MIME types.

When concat_unique is set to off, it allows for more flexibility by permitting the concatenation of files with different MIME types in a single request. This means users can concatenate, for instance, both CSS and JavaScript files in one operation, as demonstrated in the URL http://example.com/static/??style1.css,script.js. However, enabling this feature can lead to complications in file handling, especially if the resulting combinations of files are not compatible across different MIME types. Thus, careful management of the content being concatenated is crucial when this directive is employed.

Config Example

location /static/ {
    concat on;
    concat_unique off;
}

Setting concat_unique off allows concatenation of different MIME types, but this may lead to unexpected results if the file types are incompatible.

Users must ensure that the concatenated file formats are appropriate for the context in which they will be used, especially when mixing JavaScript and CSS files.

← Back to all directives