Serving Brotli static pre-compressed files
-
Hello,
I am trying to serve pre-compressed brotli files (HTML, CSS, JS).
In the AO cache, I only can generate the gzipped files but it appears that my server/CDN is compressing it on the fly and serving it with brotli, so the .html.gz, .css.gz and .js.gz pre-compressed are useless.In order to serve the brotli version, I found this .htaccess rules :
https://httpd.apache.org/docs/2.4/fr/mod/mod_brotli.html#precompressed<IfModule mod_headers.c> RewriteCond "%{HTTP:Accept-encoding}" "br" RewriteCond "%{REQUEST_FILENAME}\.br" "-s" RewriteRule "^(.*)\.css" "$1\.css\.br" [QSA] RewriteCond "%{HTTP:Accept-encoding}" "br" RewriteCond "%{REQUEST_FILENAME}\.br" "-s" RewriteRule "^(.*)\.js" "$1\.js\.br" [QSA] RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-brotli:1] RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-brotli:1] <FilesMatch "(\.js\.br|\.css\.br)$"> Header append Content-Encoding br Header append Vary Accept-Encoding </FilesMatch> </IfModule>Is this rule the good one to use ?
I found a lot of documentation discussing mainly about nginx but not so much about apache even if some are saying it is now mainly enabled by hosters.
I have seen that you added the function to manage brotli compression in autoptimizeCache.php but I can’t make it work.
I also added this filter you advised to use with no success :
add_filter( 'autoptimize_filter_cache_create_static_gzip', '__return_true' );Can you let me know what I should do in order to create and store the static version of the
.brfiles as it is done with the.gzfiles.
Also is there something to do to make Cache Enabler do the same with.htmlfiles ?Thank you for your help
The topic ‘Serving Brotli static pre-compressed files’ is closed to new replies.