How to Configure Apache to Gzip Your Components
Compressing your Web components will help speed up your Website. The majority of your visitors will benefit as most all Web browsers support gzip compression. You’ll want to compress all text, which includes html, css, javascript, xml, json, etc.
Apache 2.x uses mod_deflate, and all you need to do is add the following to your <VirtualHost> section of your Apache configuration:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
All you truly need is the first line. The BrowserMatch lines are there to handle issues with old browsers.
You can read all about gzipping by reading Yahoo!’s Best Practices for Speeding Up Your Website guide.
Also, be sure to check out our post on How to Set an Expires Header in Apache, which will also help speed up your Website.
7 Comments to How to Configure Apache to Gzip Your Components
Leave a Reply
About Justin
Search
Recent Posts
- A Simple Formula for Evaluating Risk
- Not Having a Plan B Makes Plan A More Successful
- Easy Rails API Authentication Using restful-authentication
- God Init.d Script for CentOS
- Private, Authenticated RSS Feeds in Rails
- A Private Web Beta in Seconds with Prefinery
- Backup Your WordPress Blog to Amazon S3 using Ruby
- How to Set an Expires Header in Apache



Please Can you show me step by step guide to make it workable, That is how to gzip the images and all. i have access to htaccess, and how to set header expire options
Adding the “AddOutputFilterByType” line to your Apache config file (usually httpd.conf or apache2.conf) is all you have to do. It’s the only step. You don’t actually have to gzip your files — Apache takes care of that for you.
This is great! Thanks!
Did you provoked it? Its exelent i like this playful much.
Looking forward to reading more of your articles in the future.Go for it.
Thanks a lot for the article! very helpful! Worked like a charm!!
can you please tell where is this file httpd.conf on hosting. i am using virtual dedicated server on godaddy with centOS and appache.