concat
Enables the HTTP concatenation of multiple files in NGINX.
Description
The concat directive in the NGINX HTTP Concatenation module allows users to consolidate multiple CSS or JavaScript files into a single response. By using a special URL syntax with a double question mark (??), such as http://example.com/??file1.css,file2.css, clients can request several files at once. The server processes this request, concatenating the specified files and serving them as a single entity in the appropriate MIME type, which helps reduce the number of HTTP requests and thus improves load times. Additionally, the configuration provides parameters for maximum files to concatenate and controls whether only uniform MIME types can be concatenated.
Config Example
location /static/ {
concat on;
concat_max_files 10;
concat_types application/javascript text/css;
concat_delimiter ',';
}Ensure that the URL is formed correctly with the double question mark.
Be cautious of the max_files limit, which may lead to errors if exceeded.
Different MIME types cannot be concatenated unless concat_unique off is specified.