Output compression using Gzip and Deflate is a common feature of modern webservers. Webpages can be compressed by the server and then decompressed by the client seamlessly.
By default (at least on debian/ubuntu) Apache has a module installed and enabled called mod_deflate. While great, here is the default configuration:
AddOutputFilterByType DEFLATE text/html text/plain text/xml
Now at a glance this is fine, But modern webpages consist of more than just html, we have CSS, Javascript, RSS and even JSON, all of which can benefit from compression but aren’t enabled by default.
Here’s a modified config file that will compress these files:
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/javascript text/css application/rss+xml application/json
This config is usually located at /etc/apache2/mods-enabled/deflate.conf
.
With this done jQuery (minified) goes down from 54KB to just 16KB of data send to the client :D