Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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
</Location>

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

share|improve this answer
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 '11 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 '11 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 '11 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 '11 at 16:27

Check out http://gzipwtf.com/. Here you can see which files served are compressed while being served by the server.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.