From e5e0f074a7fadfd00268b2575f5ff15bb9846ab9 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Thu, 4 Apr 2024 18:59:34 -0700 Subject: [PATCH] Bug 36531: Serve text/javascript compressed, like application/javascript is Koha serves static .js files as application/javascript (if /etc/mime.types says to) and serves them compressed, but output_with_http_headers uses the currently-correct text/javascript mimetype, and Koha doesn't compress that. Test plan: 1. Set the preference EnableAdvancedCatalogingEditor to Enable. 2. Open the browser Web Developer Tools to the Network tab 3. Load Cataloging - Advanced editor 4. Click on the line for the framework?frameworkcode=&callback=define load 5. Note the content-type text/javascript, no Content-Encoding line, and the size of 1.9MB 6. Apply the patches from bug 36463 if they haven't been pushed, then this patch, and reset_all 7. Repeat steps 1-4, and note a Content-Encoding: gzip header and a Transferred size around 160KB Signed-off-by: David Nind Signed-off-by: Nick Clemens --- debian/templates/apache-shared.conf | 2 +- etc/koha-httpd.conf | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/debian/templates/apache-shared.conf b/debian/templates/apache-shared.conf index e3ad79cc040..b9e3ce9b855 100644 --- a/debian/templates/apache-shared.conf +++ b/debian/templates/apache-shared.conf @@ -37,7 +37,7 @@ SetEnv PERL5LIB "/usr/share/koha/lib" # Compress content with type html, text, and css, ... AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml - AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json + AddOutputFilterByType DEFLATE application/javascript text/javascript application/x-javascript application/json DeflateCompressionLevel 9 diff --git a/etc/koha-httpd.conf b/etc/koha-httpd.conf index 71160a5b7a8..f09bfaf91c4 100644 --- a/etc/koha-httpd.conf +++ b/etc/koha-httpd.conf @@ -50,6 +50,7 @@ mod_gzip_item_exclude rspheader Content-Type:image/* mod_gzip_item_include file \.js$ mod_gzip_item_include mime ^application/javascript$ + mod_gzip_item_include mime ^text/javascript$ mod_gzip_item_include mime ^application/x-javascript$ mod_gzip_item_include file \.php$ mod_gzip_item_include mime ^text/html$ @@ -62,7 +63,7 @@ # Compress content with type html, text, and css, ... AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml - AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json + AddOutputFilterByType DEFLATE application/javascript text/javascript application/x-javascript application/json DeflateCompressionLevel 9 @@ -189,6 +190,7 @@ mod_gzip_item_exclude rspheader Content-Type:image/* mod_gzip_item_include file \.js$ mod_gzip_item_include mime ^application/javascript$ + mod_gzip_item_include mime ^text/javascript$ mod_gzip_item_include mime ^application/x-javascript$ mod_gzip_item_include file \.php$ mod_gzip_item_include mime ^text/html$ @@ -201,7 +203,7 @@ # Compress content with type html, text, and css, ... AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml - AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json + AddOutputFilterByType DEFLATE application/javascript text/javascript application/x-javascript application/json DeflateCompressionLevel 9 -- 2.30.2