Compression is particularly important on Amazon Web Services (AWS) because:
- HTML is very redundant and bulky
- Smaller files are sent to the client faster
- AWS charges you based upon OUTPUT bandwidth; smaller files = less bandwidth usage per file
Simple activation of mod_deflate
- Log in to your instance via the SCP client then open the apache2 virtual hosts configuration file (“/etc/httpd/conf.d/vhosts.conf” for the default setup mentioned in other instructions here).
- Add the “AddOutputFilterByType DEFLATE text/html text/plain text/xml” Filter to each virtual host (virtual hosts are the groupings starting with “<VirtualHost “). You should inclose the filter in a conditional module statement (“<IfModule xxxx.x>”) to make sure your web server keeps running even if you happen to remove the deflate module.
- Save the virtual hosts configuration file.
- Open the SSH client and transfer to the root user (“sudo su”)
- Restart the apache2 service (“service httpd restart”).
The changes to the virtual hosts configuration file
- <VirtualHost *:80>
- <IfModule mop_deflate.c>
- AddOutputFilterByType DEFLATE text/html text/plain text/xml
Summary of command line inputs
- $ sudo su
- $ service httpd restart