From 322a59b31ce705458fdaccc1579e0c2ee9e27b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Sat, 26 Sep 2026 09:38:03 +0200 Subject: [PATCH] feat: offer brotli for the assets the webhost now serves itself --- public/.htaccess | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/public/.htaccess b/public/.htaccess index 3bc1719d..d47a22eb 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -75,6 +75,58 @@ AddType image/webp .webp +# Brotli, where the host has the module. It beats gzip by roughly 15-20% on the theme's +# minified css/js at no measurable cost, and falls back to the mod_deflate block above for +# clients that do not announce `br` - which is also what happens wholesale if the module is +# missing, because the whole block is then skipped. +# +# The type list is deliberately the same one mod_deflate gets: `no-gzip` below switches gzip +# off for every br-capable client, so a type listed for DEFLATE only would reach those +# clients uncompressed. + + # Both filters would otherwise run for a client announcing `br, gzip` and gzip the brotli + # output on top of itself. mod_deflate honours `no-gzip`, so brotli wins where it is + # offered and gzip keeps everyone else. + + SetEnvIfNoCase Accept-Encoding "(^|[\s,])br($|[\s,;])" no-gzip + + + + AddOutputFilterByType BROTLI_COMPRESS application/atom+xml \ + application/javascript \ + application/json \ + application/ld+json \ + application/manifest+json \ + application/rdf+xml \ + application/rss+xml \ + application/schema+json \ + application/vnd.geo+json \ + application/vnd.ms-fontobject \ + application/x-font-ttf \ + application/x-javascript \ + application/x-web-app-manifest+json \ + application/xhtml+xml \ + application/xml \ + font/eot \ + font/opentype \ + image/bmp \ + image/svg+xml \ + image/vnd.microsoft.icon \ + image/x-icon \ + text/cache-manifest \ + text/css \ + text/html \ + text/javascript \ + text/plain \ + text/vcard \ + text/vnd.rim.location.xloc \ + text/vtt \ + text/x-component \ + text/x-cross-domain-policy \ + text/xml + + + ### End: Compression ###