How to enable gzip compression on Apache
mod_deflate came with 2nd generation of Apache web-server. It's an effective replacement of its predecessor – mod_gzip module that was used in Apache 1.3.xx.
Why choose mod_deflate module?
That's a reasonable question since there are plenty of alternatives. For example, additional plugins for popular CMS and different solutions based on mod_rewrite module. But when you use additional PHP plugins it greatly increases system resourses consumpltion and using mod_rewrite module that returns compressed objects instead of original ones is simply inconvinient. Mod_deflate module doesn't have these disatvantages and is easy to configure. Besides, it provides the great balance in performance and compression level on one hand, and moderate system resourses usage on the other.
Results of site analysis before activating gzip compression with mod_deflate
Gzip compression with mod_deflate module: activation and configuring
Some guides recommend to activate compression of all files except for files that can't be compressed like archives, images, multimedia files, etc. With this aproach you should replace line 6 with these:
SetOutputFilter DEFLATE <IfModule mod_setenvif.c> SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary </IfModule>
This fragment of Apache web server configuration file activates compressing of all files and with mod_sensitif module active forbids compressing of archives with .rar and .zip extensions, images with .gif, .jpg and .png extensions, videofiles with .avi, .mov and .mp4 extensions and audiofiles with .mp3 extension. I'm not fond of this approach since it can affect much more objects than required. There are more directives for subtle configuring of mod_deflate module. But they can be used only in httpd.conf/vhost.conf files which arent available on most hostings. But for most existing sites the directives described in this article will be more than enough.
Results of site analysis after activating gzip compression with mod_deflate module
if you use Apache 2.x on your server I strongly recommend taking mod_deflate module into consideration. It allows to reduce the traffic generated by your site at least three times and to increase page loading speed of your site just that much.
The next step you should make is to leverage browser caching in Apache.
This work is licensed under a Creative Commons Attribution-NoDerivs 3.0 United States License.
just awesomeness!!! thanks alot :) keep it up man!!
There is a problem with compression. Essential for all your recommendations, but the result was negative. On the server mod_deflate works, but mod_headers is not. I'm using WordPress. Thank you for your help.
Then just install it, what is the problem? :)
Communicated with the server administrator, included mod_headers, mod_filter and mod_expires, but compression and still does not work. I can not understand why??? HTML compression works even without any .htaccess or plugins, but CSS/JS compression won't work. In my phpinfo(): HTTP_ACCEPT_ENCODING gzip,deflate,sdch Accept-Encoding gzip,deflate,sdch Thank you for response.
Probably lack of mod_mime. phpinfo is meaningless here, it's done on http server level. If you have an SSH access to your server, you can check which apache modules are installed and activated by this command: httpd -t -D DUMP_MODULES
How To Enable Gzip Compression Centos...........http://goo.gl/2SlUpS
Priya Sharma2014-06-30 07:24:18
How To Enable Gzip Compression Centos...........http://mytecharticle.com/?p=1598
GZip compression is working in localhost but it's not working on server side please help me.
Gzip is working in localhost but it's not working on apache server 2.2 side please help me.
Simply awesome!! Thank you so much!
Kevin Morley @w1ggan2014-10-12 01:01:07
Just gotta say thank you, web page loading very quick (to a human) now :-)
can u tell how to configure apache for the mime type application/binary and application/json?
Enabling GZIP2014-11-12 11:06:34
A great tool to check if your site has GZIP compression: http://www.giftofspeed.com/gzip-test/
Got a comment?
All Rights Reserved.