I'm running a CentOS server and I want to save bandwidth, make pages faster, all that. How can I turn on http compression? Is it a module I enable for all sites? Can it be that simple?

  • Check out gzipwtf.com. Here you can see which files served are compressed while being served by the server.
    – user23221
    Sep 11, 2012 at 15:15

1 Answer 1


Use mod_deflate.

Add this to your apache config:

LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
<Location />
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css

Obviously if the path your system uses for apache modules differs then you'll need to use the correct path.

  • 1
    For the CentOS 5 httpd rpm, mod_deflate is included and already loaded. You do need to use the DEFLATE output filter as bahamat describes above.
    – jsbillings
    Feb 3, 2011 at 3:47
  • I added the LoadModule to a conf in conf.d and yeah, after restarting apache it's already loaded. How can I tell if it's serving everything compressed and why would google keep telling me to compress everything? Guess those are questions best asked elsewhere.
    – tooshel
    Feb 3, 2011 at 17:08
  • 1
    If you look at the headers (each browser has its own way, or use a sniffer such as wireshark or tcpflow to see them) one of them will be something like Content-Encoding:gzip. You should use an actual desktop browser (e.g., firefox, chrome, etc) rather than a lower level client (lynx, curl, telnet, etc) because the lower level clients may not support/request/advertise compression capability.
    – bahamat
    Feb 3, 2011 at 17:56
  • I think the problem is I needed to add AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css to httpd.conf. Now it seems to be working.
    – tooshel
    Feb 4, 2011 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .