Apache Global Output Compression
Something we’ve been playing with for a while… global gzip / deflate compression on apache servers. Naturally you can do this in php or via .htaccess but why not do it globally from the apache configuration?
Decided to give it a whirl on some of our own dedicated servers the other day.
Dowsides:
- Increases CPU load
- Increases CPU load
- Increases CPU load
Obviously there is only one major downside. The server has to compress the page on request and this takes processor power to do.
Upsides:
- Reduces bandwidth
- Increases client perceived responsiveness due to reduced page side
edit the main httpd.conf /etc/httpd/conf/httpd.conf for us:
#Alans gzip optimisations
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
Obviously you need to have the mod_deflate DSO added to apache (default configurations from RedHat / CentOS have this). It’s also advatageous to note what you want compressing – it’s not worth compressing zip files for example or binary files as you are simply wasting CPU power.
![]()
![]()
Success! We’ve since enabled this on our shared platforms as we are not currently CPU limited.