From 24bc96ad095ea2d5650be8827eee641a32ca3c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 17 Nov 2021 12:30:12 +0100 Subject: [PATCH] Allow to serve static WebAssembly and TensorFlow Lite files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since Talk 13 (and thus Nextcloud 23) WebAssembly (.wasm) and TensorFlow Lite (.tflite) files need to be loaded from the web server to provide certain features (like the background blur in the WebUI). Those files can be treated in a similar way to other static resources, and there should not be any problem caching or compressing them. However, as compressed TensorFlow Lite files are only ~12% smaller, the compression directive depends on the MIME type and there is no standard MIME type for TensorFlow Lite files it is not worth to compress them. Moreover, no directives to compress WebAssembly files were added either, as it seems that they would override any other compression directives set in the default server configuration; for reference it could be done with something like: AddOutputFilterByType DEFLATE application/wasm Depending on the setup "application/wasm" may not be associated with ".wasm" files, so the directive was added just in case, as otherwise browsers log a warning. Signed-off-by: Daniel Calviño Sánchez --- .htaccess | 3 ++- lib/private/Setup.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.htaccess b/.htaccess index 4986f7d380f..ce84f0698c7 100644 --- a/.htaccess +++ b/.htaccess @@ -43,7 +43,7 @@ # Add cache control for static resources - + Header set Cache-Control "max-age=15778463" @@ -75,6 +75,7 @@ AddType image/svg+xml svg svgz + AddType application/wasm wasm AddEncoding gzip svgz diff --git a/lib/private/Setup.php b/lib/private/Setup.php index a7f0f190fa2..f1ad04671f9 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -530,7 +530,7 @@ class Setup { $content .= "\n Options -MultiViews"; $content .= "\n RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]"; $content .= "\n RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]"; - $content .= "\n RewriteCond %{REQUEST_FILENAME} !\\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg|map|webm|mp4|mp3|ogg|wav)$"; + $content .= "\n RewriteCond %{REQUEST_FILENAME} !\\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg|map|webm|mp4|mp3|ogg|wav|wasm|tflite)$"; $content .= "\n RewriteCond %{REQUEST_FILENAME} !/core/ajax/update\\.php"; $content .= "\n RewriteCond %{REQUEST_FILENAME} !/core/img/(favicon\\.ico|manifest\\.json)$"; $content .= "\n RewriteCond %{REQUEST_FILENAME} !/(cron|public|remote|status)\\.php";