From ce9cd7513e05f9533cc49514b88a43b03be520a8 Mon Sep 17 00:00:00 2001 From: Hecht Date: Mon, 17 Jun 2024 22:17:05 +0200 Subject: [PATCH] added brotli compression for godot binaries --- public/.htaccess | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/public/.htaccess b/public/.htaccess index 3646650..886dacf 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -57,6 +57,29 @@ DirectoryIndex index.php # Rewrite all other queries to the front controller. RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ %{ENV:BASE}/index.php [L] + + # Brotli + # If the web browser accept brotli encoding ... + RewriteCond %{HTTP:Accept-encoding} br + # ... and the web browser is fetching a probably pre-compressed file ... + RewriteCond %{REQUEST_URI} .*\.(pck|wasm)$ + # ... and a matching pre-compressed file exists ... + RewriteCond %{REQUEST_FILENAME}\.br -s + # ... then rewrite the request to deliver the brotli file + RewriteRule ^(.*) $1.br + # For each file format set the correct mime type (otherwise brotli mime type is returned) and prevent Apache for recompressing the files + RewriteRule "\.pck\.br$" "-" [T=application/octet-stream,E=no-brotli,E=no-gzip] + RewriteRule "\.wasm\.br$" "-" [T=application/wasm,E=no-brotli,E=no-gzip] + + + # Prevent mime module to set brazilian language header (because the file ends with .br) + RemoveLanguage .br + # Set the correct encoding type + Header set Content-Encoding br + # Force proxies to cache brotli & non-brotli files separately + Header append Vary Accept-Encoding + +