]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/piwik/templates/default/apache.erb
Optimise loading of piwik javascript
[chef.git] / cookbooks / piwik / templates / default / apache.erb
index 8f27414ba3f69629d00469c1ded2d1538a20ef99..58703f41b53622f73c5db8643bb3abaaa70abdb3 100644 (file)
 
 <Directory /srv/piwik.openstreetmap.org>
        Require all granted
 
 <Directory /srv/piwik.openstreetmap.org>
        Require all granted
+
+       ExpiresActive On
+       RewriteEngine on
+
+       RewriteCond "%{HTTP:Accept-encoding}" "gzip"
+       RewriteCond "%{REQUEST_FILENAME}\.gz" -s
+       RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA]
+
+       RewriteRule "\.js\.gz$"  "-" [T=text/javascript,E=no-gzip:1]
+
+       <FilesMatch "\.js\.gz$">
+               Header append Content-Encoding gzip
+               Header append Vary Accept-Encoding
+       </FilesMatch>
+
+       <FilesMatch "(\.js|\.js\.gz)$">
+               ExpiresDefault "access plus 1 week"
+               Header set Cache-Control "max-age=604800"
+       </FilesMatch>
 </Directory>
 </Directory>