Websites are getting more and more complicated and contain multiple CSS and JavaScript files as well as multiple images, even the simpler ones.
If you are using a content management system like WordPress, Joomla and Drupal or an ecommerce solution such as Magento, Actinic and CubeCart then you will certainly have multiple web files with CSS and JavaScript to deliver your dynamic and functionl web pages.
So to ensure your site is nice and fast for your users theres a real quick and easy way to implement a bit of compression on all those files with mod_deflate. Ill look at other methods such as mod_gzip and compression without these modules installed in a future article.
If your server supports this (check with a php info file or ask your host) then you can add some compression in the .htaccess file. You will probably want to double check the browser that is accessing the webpage supports compression also, about 90% of them do, so well add that to the .htaccess too.
The following needs to go in your .htaccess file and will enable mod_deflate on your files.
# place filter DEFLATE on all outgoing content
SetOutputFilter DEFLATE
# do some browser checking for compression support
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# exclude content we cant compress
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rpm|ico|iso|gz|bz2)$ no-gzip dont-vary
# properly handle file behind proxys
Header append Vary User-Agent env=!dont-vary
Thats it you are now compressing files for speedy delivery of your content!
Ill be adding other methods for speeding up your websites and conforming with yahoos YSlow checks later but this on its own should be a big help.
