apache-mod-brotli icon indicating copy to clipboard operation
apache-mod-brotli copied to clipboard

Implementation instructions with html5 Apache server config

Open XhmikosR opened this issue 8 years ago • 2 comments

Hello.

I'm thinking to give mod_brotli a go. But before that, I'm wondering about compatibility.

Since I'm using Apache Server Configs, I was wondering what are the needed changes for maximum compatibility.

The relevant part from https://github.com/h5bp/server-configs-apache/blob/2.14.0/dist/.htaccess:

<IfModule mod_deflate.c>

    # Force compression for mangled `Accept-Encoding` request headers
    # https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html

    <IfModule mod_setenvif.c>
        <IfModule mod_headers.c>
            SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
            RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
        </IfModule>
    </IfModule>

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    # Compress all output labeled with one of the following media types.
    #
    # (!) For Apache versions below version 2.3.7 you don't need to
    # enable `mod_filter` and can remove the `<IfModule mod_filter.c>`
    # and `</IfModule>` lines as `AddOutputFilterByType` is still in
    # the core directives.
    #
    # https://httpd.apache.org/docs/current/mod/mod_filter.html#addoutputfilterbytype

    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE "application/atom+xml" \
                                      "application/javascript" \
                                      "application/json" \
                                      "application/ld+json" \
                                      "application/manifest+json" \
                                      "application/rdf+xml" \
                                      "application/rss+xml" \
                                      "application/schema+json" \
                                      "application/vnd.geo+json" \
                                      "application/vnd.ms-fontobject" \
                                      "application/x-font-ttf" \
                                      "application/x-javascript" \
                                      "application/x-web-app-manifest+json" \
                                      "application/xhtml+xml" \
                                      "application/xml" \
                                      "font/eot" \
                                      "font/opentype" \
                                      "image/bmp" \
                                      "image/svg+xml" \
                                      "image/vnd.microsoft.icon" \
                                      "image/x-icon" \
                                      "text/cache-manifest" \
                                      "text/css" \
                                      "text/html" \
                                      "text/javascript" \
                                      "text/plain" \
                                      "text/vcard" \
                                      "text/vnd.rim.location.xloc" \
                                      "text/vtt" \
                                      "text/x-component" \
                                      "text/x-cross-domain-policy" \
                                      "text/xml"

</IfModule>

Is it just a matter of using AddOutputFilterByType BROTLI;DEFLATE "type"?

Thanks in advance!

XhmikosR avatar Oct 09 '16 12:10 XhmikosR

Implementation instructions with html5 Apache server config

I think you refer to H5BP (html5 boilerplate)

szepeviktor avatar Feb 16 '17 17:02 szepeviktor

https://httpd.apache.org/docs/2.4/mod/mod_filter.html#addoutputfilterbytype Maybe specifying more filters messes things up.

Try copying the whole AddOutputFilterByType line and replace DEFLATE with BROTLI but keep the original line too.

szepeviktor avatar Feb 16 '17 17:02 szepeviktor