How do I enable HTTP compression under apache2?

Solution 1:

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>

Solution 2:

As the Wikipedia entry you link to notes, you can use mod_deflate or mod_gzip. See here an example with mod_gzip, which is what I use.

Solution 3:

<VirtualHost *:80>
   ...     
   DeflateBufferSize 16384
   DeflateCompressionLevel 5
   DeflateMemLevel 9
   DeflateWindowSize 15

   <Location / >
      AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
   </Location>
   ...
</VirtualHost>