Support

Admin Tools

#43394 Nginx setup with Brotli support ?

Posted in ‘Admin Tools for Joomla!’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
6.1.14
PHP version
8.5.11
Admin Tools version
7.9.3

Latest post by ssnobben on Monday, 05 October 2026 08:20 CDT

ssnobben
Hi for Nginx setup with Admin Tools pro I wonder how you can enable Brotli and what the advice is? or any else comments about this... Joomla standard htaccess file have this in it dont see anything of this in Admin Tools Nginx config file though: ## GZIP & BROTLI ## These directives are only enabled if the Apache mod_headers module is enabled. ## This section will check if a .gz file exists and if so will stream it ## directly or fallback to gzip any asset on the fly ## If your site starts to look strange after enabling this file, and you see ## ERR_CONTENT_DECODING_FAILED in your browser console network tab, ## then your server is already gzipping css and js files and you don't need this ## block enabled in your .htaccess # Serve gzip compressed CSS files if they exist # and the client accepts gzip. RewriteCond "%{HTTP:Accept-encoding}" "gzip" RewriteCond "%{REQUEST_FILENAME}\.gz" -s RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA] # Serve gzip compressed JS files if they exist # and the client accepts gzip. RewriteCond "%{HTTP:Accept-encoding}" "gzip" RewriteCond "%{REQUEST_FILENAME}\.gz" -s RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA] # Serve correct content types, and prevent mod_deflate double compression. RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1] RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1] # Serve correct encoding type. Header set Content-Encoding gzip # Force proxies to cache gzipped & # non-gzipped css/js files separately. Header append Vary Accept-Encoding

nicholas
Akeeba Staff
Manager

There is a reason why this is not supported for NginX. Actually two reasons, closely related.

On Apache we can use a combination of HTTP header detection, environment variable setting, and conditional redirection to have the server serve a precompressed file when the client claims to support the relevant encoding.

In NginX this trick is not possible. You would need the ngx_http_gzip_static_module module which does ship with the mainline NginX source distribution, but it has to be explicitly enabled with the --with-http_gzip_static_module compile-time option. Since this is rarely the case with commercial hosts and because referencing the gzip_static and gzip_vary it provides when is not installed would result in the server not starting I chose not to implement it at all. But more on that later.

Brotli support has been removed from Joomla's htaccess.txt because they couldn't make it work without double-encoding; they decided it's best removed than risk it cause problems. I made it work in Apache, but it was a freaking chore and a half as you can grasp by the complexity of the generated code.

On NginX there is nothing similar to ngx_http_gzip_static_module for Brotli.

That said, all of that is absolutely pointless. Any server CPU released the last 15 years is more than capable enough to Gzip-compress static CSS and JS on the fly. The difference I measured between statically compressed files and dynamically compressed files when hammering a very feeble server with requests was below measurement error. The only real world use case where pre-compressing static media makes sense is large scale deployments which are NOT something you'd be using Joomla for.

Brotli takes a bit longer, making the measured difference between dynamic and static compression be around 10 msec (0.01 seconds) under the same test, just above the measurement error threshold of 8 msec, giving a very low confidence that there is a meaningful difference. Even worse, the difference in size between Gzip and Brotli compressed files shipped with Joomla was under 5% which made zero practical difference: a single slightly unoptimized image would have a much larger effect.

To top it all up, if you have a busy site which would benefit from a single digit millisecond performance differences in page load you'd very likely be using a caching CDN like CloudFlare to serve your site. Guess what? They can compress those files for you and keep those compressed files cached on their side, completely nullifying the need for you to deal with that on your side.

Which is to say: if you have a slow site the pre-compressed CSS and JS files will have absolutely no practical impact whatsoever. Most of your performance issues are in loading a tonne of unnecessary CSS and JS, unoptimized images, and your server itself. Trying to fix that with NginX / Apache tricks is not going to help you any. You will spend a lot of time for marginal gains that have zero observable performance impact. If anything, time-to-first-byte, FCP and LCP will have a far more pronounced impact on how your users perceive your site's speed.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

ssnobben
Ok great explanation and thks for this answers! Appreciated.. closing

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!