Configure Brotli per-account
As a server administrator, I would like to be able to configure Brotli on a per-domain basis, allowing each cPanel User to enable or disable it per-account, so that I can offer Brotli support without causing problems for users that don't require it.
=================
mod_brotli has been recently released in the April 3 EasyApache update: https://forums.cpanel.net/threads/easyapache-4-update-april-3-2018.625739/
Unfortunately installing mod_brotli configures serverwide rules. This results in a 'double compression' issue with websites which use pre-compressed gzip css and JS files. Websites fail to load on Brotli enabled browsers (Chrome) and show the error ERR_CONTENT_DECODING_FAILED.
Instead of serverwide rules it would be better if mod_brotli.conf simply loaded the Brotli module and allowed the user to enable / disable brotli compression themselves via .htaccess. Eventually this could be controlled by the 'Optimize Website' plugin in the frontend of cPanel, which could generate the .htaccess rules for the cPanel user.
This would bring mod_brotli inline with the way mod_deflate works on cPanel and immediately resolve the 'double compression' issues encountered by allowing users to enable / disable brotli compression.
Is there any update regarding this feature? It seems to me that it's a very important feature. It would let me enable Brotli only on accounts/websites that I know can use it.
My concern is, if I enable Brotli in Easy Apache 4 and that enables it server wide, then a number of my sites may have problems (gzip stops working or maybe site failing to load at all).
What I think we need is a Cpanel solution to enable Brotli (in the Optimize Website page), with a fall back to Gzip for browsers who don't support Brotli.
Is there any update regarding this feature? It seems to me that it's a very important feature. It would let me enable Brotli only on accounts/websites that I know can use it.
My concern is, if I enable Brotli in Easy Apache 4 and that enables it server wide, then a number of my sites may have problems (gzip stops working or maybe site failing to load at all).
What I think we need is a Cpanel solution to enable Brotli (in the Optimize Website page), with a fall back to Gzip for browsers who don't support Brotli.
If you're just dealing with Wordpress sites. I did the following.
Installed brotli via EasyApache.
Commented out the lines in /etc/apache2/conf.d/brotli.conf
to not enable it server-wide.
For non-wordpress sites you should be able to copy the contents of the brotli.conf into the .htaccess of a site.
For wordpress, if you use W3 Total Cache to pre-build cache files, Brotli support is built in and can be assigned individually to HTML / XML files & CSS & JS in case you want to mix and match gzip and brotli. This is done in the Browser Cache section. Brotli is slower than gzip for on-the-fly compression, so if you're not using pre-built cached files you may want to stick with gzip.
Note the W3 Total Cache plugin requires the Brotli PHP Extension to be installed. I installed with the following instructions:
https://yeahlinux.com/install-brotli-apache-module-and-php-extension-in-cpanel-ea-4/
Couple this with minification of at least css & js files and you can really speed things up. Currently don't recommend page minification with W3TC due to a bug with the minified pages not including the media query string properly to force busting of the cache when css and js is updated.
If you're just dealing with Wordpress sites. I did the following.
Installed brotli via EasyApache.
Commented out the lines in /etc/apache2/conf.d/brotli.conf
to not enable it server-wide.
For non-wordpress sites you should be able to copy the contents of the brotli.conf into the .htaccess of a site.
For wordpress, if you use W3 Total Cache to pre-build cache files, Brotli support is built in and can be assigned individually to HTML / XML files & CSS & JS in case you want to mix and match gzip and brotli. This is done in the Browser Cache section. Brotli is slower than gzip for on-the-fly compression, so if you're not using pre-built cached files you may want to stick with gzip.
Note the W3 Total Cache plugin requires the Brotli PHP Extension to be installed. I installed with the following instructions:
https://yeahlinux.com/install-brotli-apache-module-and-php-extension-in-cpanel-ea-4/
Couple this with minification of at least css & js files and you can really speed things up. Currently don't recommend page minification with W3TC due to a bug with the minified pages not including the media query string properly to force busting of the cache when css and js is updated.
Thanks for the replies. :)
Yep, I'm running a mix of Joomla and Wordpress sites. Both platforms are Gzipping, together with Cpanel Optimize Websites feature.
I get the idea, so I disable Gzip on Cpanel and sites, then the EA4/server Brotli should take over and do its stuff.
But don't we still have a problem for older browsers that don't support Brotli (genuine question, I really don't know)? I.E. If a browser doesn't support Brotli, then completely non (huge) compressed files will be served to it.
Thanks for the replies. :)
Yep, I'm running a mix of Joomla and Wordpress sites. Both platforms are Gzipping, together with Cpanel Optimize Websites feature.
I get the idea, so I disable Gzip on Cpanel and sites, then the EA4/server Brotli should take over and do its stuff.
But don't we still have a problem for older browsers that don't support Brotli (genuine question, I really don't know)? I.E. If a browser doesn't support Brotli, then completely non (huge) compressed files will be served to it.
Most browsers have been compatible for a while so users getting uncompressed files is likely negligible.
https://caniuse.com/#feat=brotli
Using the pre-compressed file method on wordpress I mentioned allows you to do both so an older browser could request gzip and newer brotli.
Most browsers have been compatible for a while so users getting uncompressed files is likely negligible.
https://caniuse.com/#feat=brotli
Using the pre-compressed file method on wordpress I mentioned allows you to do both so an older browser could request gzip and newer brotli.
Replies have been locked on this page!