<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.3//EN" "http://tuckey.org/res/dtds/urlrewrite2.3.dtd">

<urlrewrite>
    <!--
        This xml file isn't loaded by the URLRewriteFilter directly, but is instead loaded
        by the GzipFilter, which uses this to determine which browsers and URLs to serve
        zipped content to.


        There are two request attributes to set: 'gzipResponse' and 'gzipMimeTypes'.  Note that
        both must match for a response to be gzipped.

        gzipResponse: If you set this to false, then no further processing will occur
        gzipMimeTypes: Only gzip the response if the mime type matches this.
     -->
    <rule>
        <from>.*</from>
        <set name="gzipMimeTypes">text/html,text/javascript,text/css,text/plain,application/x-javascript,application/javascript</set>
    </rule>
    <rule>
        <from>.*\.gif(\?|$)</from>
        <set name="gzipResponse">false</set>
    </rule>
    <rule>
        <from>.*\.png(\?|$)</from>
        <set name="gzipResponse">false</set>
    </rule>
    <rule>
        <from>.*\.jpe?g(\?|$)</from>
        <set name="gzipResponse">false</set>
    </rule>

    <!--
     Browser support for gzipping components:  http://schroepl.net/projekte/mod_gzip/browser.htm

     Some browsers (mainly MSIE, and early versions of Netscape) advertise themselves as supporting gzip,
     but are broken in their implementation.  Below is my results of an extensive search of the known bugs:

     Personal research (Scott Farquhar 7/Sep/07)
         - IE 5 and 6, where you are running something that uses a protocol handler:
          http://support.microsoft.com/default.aspx?scid=kb;en-us;Q313712
          http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312496
        - Over SSL, some pages that are saved to disk did not load properly:
          http://support.microsoft.com/kb/837251 (IE 6, SP1)
        - If you download an excel file gzip encoded, it does not load correctly (IE 6)
          http://support.microsoft.com/kb/331596
        - Content with "Content-Encoding: gzip" Is Always Cached Although You Use "Cache-Control: no-cache" (IE 5.5 SP2, IE 6)
          http://support.microsoft.com/kb/321722/EN-US/
        - IE stores style sheets compressed in temporary internet files:
          http://blog.joshuaeichorn.com/archives/2007/01/10/compressing-javascript-and-css/#comment-147123
        - IE does not send ETag headers back if the content was sent compressed
          http://www.jpcache.com/message.txt
          http://channel9.msdn.com/wiki/default.aspx/Channel9.InternetExplorerBugs
        - HTML pages only partially appear, HTML pages do not appear at all, or the network stops responding
          http://support.microsoft.com/default.aspx?scid=kb;en-us;823386&Product=ie600
          (Am worred about this one, but seems to be fixed in SP2, and no way to diferentiate between SP1 and SP2,
           and I'm guessing that most people have IE SP2 anyhow?)

        Also sourced from:  http://httpd.apache.org/docs/2.0/mod/mod_deflate.html#recommended

    List of user agents:  http://www.zytrax.com/tech/web/browser_ids.htm
    -->

    <rule>
        <!--
         ignore everything except text/html for Internet Explorer 4-6.
         Let IE 7 be compressed
         -->
        <condition name="user-agent">.*MSIE [4-6].*</condition>
        <from>.*</from>
        <set name="gzipMimeTypes">text/html,text/plain</set>
    </rule>
    <rule>
        <!-- don't gzip anything for Netscape Navigtor -->
        <!-- we exclude Mozilla/4.0, as MSIE pretends to be that, and there
             aren't many people using Netscape 4.0 that we have to worry about -->
        <condition name="user-agent">Mozilla/4\.[1-9].*</condition>
        <from>.*</from>
        <set name="gzipResponse">false</set>
    </rule>
    <rule>
        <!-- don't gzip anything for Netscape Navigtor -->
        <condition name="user-agent">Mozilla/[2-3].*</condition>
        <from>.*</from>
        <set name="gzipResponse">false</set>
    </rule>
</urlrewrite>
