How to enable HTTP compression under apache2

apache-2.2compression

How do I configure Apache2 to support HTTP compression?

Best Answer

This requires the deflate module, so enable that. Under Ubuntu (which is what I'm using), the command for that is a2enmod deflate.

Then, use SetOutputFilter on your Proxy or Directory directive:

<ProxyMatch "^http://localhost:8080/($|app/)">
    Order allow,deny
    Allow from all
    SetOutputFilter Deflate
</ProxyMatch>

Or:

<Directory /var/www>
    Order allow,deny
    Allow from all
    SetOutputFilter Deflate
</Directory>