You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Scott A. Wozny" <sa...@hotmail.com> on 2019/09/20 23:50:09 UTC

[users@httpd] mod_brotli vs / and / or / xor mod_deflate

Greetings Apache Gurus,

I am presently trying to form a content compression strategy for a new Apache 2.4 httpd server and have been looking at the mod_brotli and mod_deflate modules.  The first thing I noticed about them, comparatively, is how very similar they are in terms of functionality, directives, etc.  This led me to looking into how they compare in practical use and the summary of what I believe I found was that Brotli can have superior compression for the same workload, but is not as widely supported.

So my question to the list is this:  Can I, with a reasonable level of convenience, install and use both to get the best of both worlds?  Is there any advantage to doing so or does the hassle of managing 2 types of compression (my intention would be to pre-compress what content I can to minimize the ongoing CPU hit) negate any bandwidth savings I may realize with this strategy?  If using both is reasonable (and possible) how does the server determine which to serve on an asset by asset basis?  Can it be done dynamically based upon best compression result for the individual asset or do the directives have the be pre-written to favour one over the other based upon the nature of my content?

I feel I may be over thinking this in general and for a small site just using deflate with gzip will give me the best bang for my buck, but I wanted to see what other people had done and if there was a relatively straightforward way to use both in the most advantageous way possible, I'd like to consider it.

Any thoughts would be appreciated.

Thanks,

Scott

Re: [users@httpd] mod_brotli vs / and / or / xor mod_deflate

Posted by "Scott A. Wozny" <sa...@hotmail.com>.
Hi Dino,

This looks interesting.  I'll definitely need to do some more studying of a number of directives I'm not familiar with.  I will dig further.

Thanks very much for your reply,

Scott

________________________________
From: dino@tuxweb.it <di...@tuxweb.it>
Sent: September 22, 2019 4:45 AM
To: users@httpd.apache.org <us...@httpd.apache.org>
Subject: Re: [users@httpd] mod_brotli vs / and / or / xor mod_deflate

So my question to the list is this: Can I, with a reasonable level of convenience, install and use both to get the best of both worlds? Is there any advantage to doing so or does the hassle of managing 2 types of compression (my intention would be to pre-compress what content I can to minimize the ongoing CPU hit) negate any bandwidth savings I may realize with this strategy? If using both is reasonable (and possible) how does the server determine which to serve on an asset by asset basis? Can it be done dynamically based upon best compression result for the individual asset or do the directives have the be pre-written to favour one over the other based upon the nature of my content?

Yes, you can install both modules. This is how i would setup (JUST AN EXAMPLE!):

[SNIP]


<IfModule brotli_module>
# Compression
## BrotliCompressionQuality: 0-11 (default: 11)
BrotliCompressionQuality 8

## BrotliCompressionWindow: 10-24 (default: 22)
BrotliCompressionWindow 18

# Logging
# Filter note
BrotliFilterNote Input brotli_in
BrotliFilterNote Output brotli_out
BrotliFilterNote Ratio brotli_ratio

# Output filter
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/css text/xml
AddOutputFilterByType BROTLI_COMPRESS text/css
AddOutputFilterByType BROTLI_COMPRESS application/x-javascript application/javascript
AddOutputFilterByType BROTLI_COMPRESS application/rss+xml
AddOutputFilterByType BROTLI_COMPRESS application/json
# This is compressed by deflate, check deflate_module configuration block below
# AddOutputFilterByType BROTLI_COMPRESS application/xml

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

# Global output filer if necessary.
# SetOutputFilter BROTLI_COMPRESS
# SetEnvIfNoCase Request_URI \.txt$ no-br
</IfModule>

# If brotli is not installed use deflate
# <IfModule !brotli_module>
# <IfModule deflate_module>
# AddOutputFilterByType DEFLATE text/html text/plain text/xml
# AddOutputFilterByType DEFLATE text/css
# #AddOutputFilterByType DEFLATE image/jpeg image/png
# AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
# AddOutputFilterByType DEFLATE application/rss+xml
# AddOutputFilterByType DEFLATE application/xml
# </IfModule>
# </IfModule>

<IfModule deflate_module>
# here we compress application/xml using deflate instead of brotli
AddOutputFilterByType DEFLATE application/xml
</IfModule>


[/SNIP]

Ciao, Dino.

Re: [users@httpd] mod_brotli vs / and / or / xor mod_deflate

Posted by di...@tuxweb.it.
So my question to the list is this: Can I, with a reasonable level of convenience, install and use both to get the best of both worlds? Is there any advantage to doing so or does the hassle of managing 2 types of compression (my intention would be to pre-compress what content I can to minimize the ongoing CPU hit) negate any bandwidth savings I may realize with this strategy? If using both is reasonable (and possible) how does the server determine which to serve on an asset by asset basis? Can it be done dynamically based upon best compression result for the individual asset or do the directives have the be pre-written to favour one over the other based upon the nature of my content? 
Yes, you can install both modules. This is how i would setup (JUST AN EXAMPLE!):

[SNIP]
<IfModule brotli_module>
# Compression
## BrotliCompressionQuality: 0-11 (default: 11)
BrotliCompressionQuality 8

## BrotliCompressionWindow: 10-24 (default: 22)
BrotliCompressionWindow 18

# Logging
# Filter note
BrotliFilterNote Input brotli_in
BrotliFilterNote Output brotli_out
BrotliFilterNote Ratio brotli_ratio

# Output filter
AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/css text/xml
AddOutputFilterByType BROTLI_COMPRESS text/css
AddOutputFilterByType BROTLI_COMPRESS application/x-javascript application/javascript
AddOutputFilterByType BROTLI_COMPRESS application/rss+xml
AddOutputFilterByType BROTLI_COMPRESS application/json
# This is compressed by deflate, check deflate_module configuration block below
# AddOutputFilterByType BROTLI_COMPRESS application/xml

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

# Global output filer if necessary.
# SetOutputFilter BROTLI_COMPRESS
# SetEnvIfNoCase Request_URI .txt$ no-br
</IfModule>

# If brotli is not installed use deflate
# <IfModule !brotli_module>
# <IfModule deflate_module>
# AddOutputFilterByType DEFLATE text/html text/plain text/xml
# AddOutputFilterByType DEFLATE text/css
# #AddOutputFilterByType DEFLATE image/jpeg image/png
# AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
# AddOutputFilterByType DEFLATE application/rss+xml
# AddOutputFilterByType DEFLATE application/xml
# </IfModule>
# </IfModule>

<IfModule deflate_module>
 # here we compress application/xml using deflate instead of brotli
 AddOutputFilterByType DEFLATE application/xml
</IfModule>
[/SNIP]

Ciao, Dino.