summaryrefslogtreecommitdiff
path: root/.htaccess
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-10-11 23:49:48 +0000
committerDries Buytaert <dries@buytaert.net>2010-10-11 23:49:48 +0000
commit563c673ea3b8977e9f739f7979acb62abcd78310 (patch)
tree8d8f6b6d2c066f8673d2b7c5960311368a58d269 /.htaccess
parentc54107146b0173a1c090fcac488081fe46de3512 (diff)
downloadbrdo-563c673ea3b8977e9f739f7979acb62abcd78310.tar.gz
brdo-563c673ea3b8977e9f739f7979acb62abcd78310.tar.bz2
- Patch #101227 by mikeytown2, Owen Barton, grendzy: added Gzip aggregated CSS and JS.
Diffstat (limited to '.htaccess')
-rw-r--r--.htaccess25
1 files changed, 25 insertions, 0 deletions
diff --git a/.htaccess b/.htaccess
index ab8fe8d74..5fed51e0c 100644
--- a/.htaccess
+++ b/.htaccess
@@ -109,6 +109,31 @@ DirectoryIndex index.php index.html index.htm
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
+
+ # Rules to correctly serve gzip compressed CSS and JS files.
+ # Requires both mod_rewrite and mod_headers to be enabled.
+ <IfModule mod_headers.c>
+ # Serve gzip compressed CSS files if they exist and the client accepts gzip.
+ RewriteCond %{HTTP:Accept-encoding} gzip
+ RewriteCond %{REQUEST_FILENAME}\.gz -s
+ RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
+
+ # Serve gzip compressed JS files if they exist and the client accepts gzip.
+ RewriteCond %{HTTP:Accept-encoding} gzip
+ RewriteCond %{REQUEST_FILENAME}\.gz -s
+ RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
+
+ # Serve correct content types, and prevent mod_deflate double gzip.
+ RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
+ RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
+
+ <FilesMatch "(\.js\.gz|\.css\.gz)$">
+ # Serve correct encoding type.
+ Header append Content-Encoding gzip
+ # Force proxies to cache gzipped & non-gzipped css/js files separately.
+ Header append Vary Accept-Encoding
+ </FilesMatch>
+ </IfModule>
</IfModule>
# $Id$