Commit 05e649e0 authored by Richard Bowen's avatar Richard Bowen
Browse files

Add "pre-compressed content" reccipe, as per

parent c3412918
Loading
Loading
Loading
Loading
+43 −0
Changes for docs/manual/mod/mod_deflate.html.en: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ client</td></tr>
<li><img alt="" src="../images/down.gif" /> <a href="#recommended">Sample Configurations</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#enable">Enabling Compression</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#proxies">Dealing with proxy servers</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#precompressed">Serving pre-compressed
content</a></li>
</ul><h3>See also</h3>
<ul class="seealso">
<li><a href="../filter.html">Filters</a></li>
@@ -185,6 +187,47 @@ SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip</pre>

    <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">Header set Vary *</pre>
</div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="precompressed" id="precompressed">Serving pre-compressed
content</a></h2>

    <p>Since <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code> 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>

    <pre class="prettyprint lang-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;</pre>


</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="DeflateBufferSize" id="DeflateBufferSize">DeflateBufferSize</a> <a name="deflatebuffersize" id="deflatebuffersize">Directive</a></h2>
+42 −0
Changes for docs/manual/mod/mod_deflate.xml: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -178,6 +178,48 @@ 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;
    </highlight>

</section>

<directivesynopsis>
<name>DeflateFilterNote</name>
<description>Places the compression ratio in a note for logging</description>