Use the precompressed assets instead of compressing on the fly
authorTom Hughes <tom@compton.nu>
Tue, 18 Jun 2019 07:46:35 +0000 (08:46 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 18 Jun 2019 07:48:26 +0000 (08:48 +0100)
cookbooks/web/templates/default/apache.frontend.erb

index 45683bd..5944e5f 100644 (file)
 
 <Directory <%= node[:web][:base_directory] %>/rails/public>
   Require all granted
+
+  RewriteCond "%{HTTP:Accept-encoding}" "gzip"
+  RewriteCond "%{REQUEST_FILENAME}\.gz" -s
+  RewriteRule "^(.*)\.(css|js|svg)" "$1\.$2\.gz" [QSA]
+
+  RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
+  RewriteRule "\.js\.gz$"  "-" [T=text/javascript,E=no-gzip:1]
+  RewriteRule "\.svg\.gz$"  "-" [T=image/svg+xml,E=no-gzip:1]
+
+  <FilesMatch "(\.js\.gz|\.css\.gz|\.svg\.gz)$">
+    Header append Content-Encoding gzip
+    Header append Vary Accept-Encoding
+  </FilesMatch>
 </Directory>
 
 <Directory /srv/www.openstreetmap.org/rails/app/assets>