Enable deflate on your Apache Server
What is deflate I thought gzip was the way to go?
Excellent observation, gzip was the older compression style used by apache and friends. DEFLATE is the new form of gzip. As far as I can tell, there really is no difference. If you run Apache2 or higher, you run deflate, if you run anything previous, you run with gzip.
For those of you running the XAMPP package, this is a how to, for anyone else this is similar to what you need to do, but you may need to tweak a few settings.
- Get the mod_deflate plug-in enabled on your webserver. Crack open your httpd.conf file (XAMPP users will find this in /xampp/apache/conf/httd.conf), you should see "#LoadModule mod_deflate modules/mod_deflate.so". Just uncomment that - remove the '#' - and you're off to a good start.
- Restart your webserver (this may involve right-clicking or some command-linery.
- We're about half way there... Now we need to make or modify your .htaccess file to enable the compressiony goodness. add this to your .htaccess file. "SetOutputFilter DEFLATE".
- Now we need to make another .htaccess file if your js directory (you could of course just take on another "Files" tag in your current .htaccess, but lets fine tune it ;) ) this time replacing the "*.html" with a "*.js". That will enable compression on your js files (Also note that if you used 'pack' compression this might screw up all your js... badly, and may even break your page to the point of no loading. However if you're turning on gzip/deflate you used either yui or min anyway right?
- You shouldn't have to restart your server (.htaccess files are *usually* picked up on the fly), but you can if you want to, and rebooting usually only helps ("Have you tried turning it off and on again?").
If you got lost on that, here are my .htaccess files for reference :)
.htaccess in root
# compress all text & html:
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css
# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
.htaccess file in js folder
# compress all text & html:
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css
# Or, compress certain file types by extension:
<Files *.js>
SetOutputFilter DEFLATE
</Files>