]> granicus.if.org Git - apache/commitdiff
Add "pre-compressed content" recipe, as per
authorRich Bowen <rbowen@apache.org>
Tue, 14 Apr 2015 17:06:10 +0000 (17:06 +0000)
committerRich Bowen <rbowen@apache.org>
Tue, 14 Apr 2015 17:06:10 +0000 (17:06 +0000)
https://bz.apache.org/bugzilla/show_bug.cgi?id=51336

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1673470 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/mod/mod_deflate.xml

index afa4ca33ef7d77ab1097eb21fbf8923422e7d2af..847210f458dca8fa94f38faf884c5f101d6cdd92 100644 (file)
@@ -178,6 +178,51 @@ SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip
     </example>
 </section>
 
+<section id="precompressed"><title>Serving pre-compressed
+content</title>
+
+    <p>Since <module>mod_deflate</module> re-compresses content each 
+    time a request is made, some performance benefit can be derived by
+    pre-compressing the content and telling mod_deflate to serve them
+    without re-compressing them. This may be accomplished using a
+    configuration like the following:</p>
+
+    <highlight language="config">
+  &lt;IfModule mod_headers.c&gt;
+    # 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]
+
+
+    &lt;FilesMatch "(\.js\.gz|\.css\.gz)$"&gt;
+      # Serve correct encoding type.
+      Header append Content-Encoding gzip
+
+      # Force proxies to cache gzipped &amp; 
+      # non-gzipped css/js files separately.
+      Header append Vary Accept-Encoding
+    &lt;/FilesMatch&gt;
+  &lt;/IfModule&gt;
+</IfModule>
+
+
+    </highlight>
+
+</section>
+
 <directivesynopsis>
 <name>DeflateFilterNote</name>
 <description>Places the compression ratio in a note for logging</description>