Ive been looking for a way to set the DEFLATE globally and then disable it individually as needed
either in vhosts or in containers.
There are two way to configure the DEFLATE:
– INCLUDE-ALL-with-Exceptions : Compress all content except the exceptions defined
– EXCLUDE-ALL-with-Exceptions : Compress none of the contents except the exceptions defined

The feature that is not so documented, is that some environment variables are controlling how the DEFLATE filter works: Here are some:
no-gzip: If set then DEFLATE doesn’t compress the content

dont-vary: Should be combined with ‘no-gzip’ to tell the proxies that the content has changed, so that they
do not serve content cached from a client request that supports gzip and called by another client
that doesn’t support it.

gzip-only-text/html: As it says, it compresses only the contents that have the HTTP header:
Content type: text/html

Here is a good example (and a practical as well) of a configuration using this:
Note: this example uses the INCLUDE-ALL-with-Exceptions method.
——————————————————————
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

# DEFLATE or not depending on the browser type
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html


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

# Allows compress ratio statistics to be included in logs
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio

——————————————————————
# Log format example using above DEFLATE configs:
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate

This sets the DEFLATE globally and turn it off for some special files and clients that don’t support gzip well.

To turn off the DEFLATE feature for a whole virtual host do the following:
——————————————————————
# Disable the DEFLATE

SetEnv no-gzip
SetEnv dont-vary

# And then inside a container you can Re-enable the DEFLATE using

UnsetEnv no-gzip
UnsetEnv dont-vary

——————————————————————

Using the EXCLUDE-ALL-with-Exceptions method.
==============================

To use the DEFLATE on only a list of content types then use the following example:
———————————————————————————————————

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# The compression engine takes very little CPU therefore we can afford maximum compression
DeflateCompressionLevel 9

———————————————————————————————————