Speed up your website served by apache httpd in 2 mins

Slow website? Have you tried turning on file compression? If not, this tweak can speed up your website in an instant.

The apache documentation of the mod_deflate is one way to go. Add the following piece of configuration (that I have just copy-pasted from the apache docs website) to your virtual host config (it requires the mod_headers and mod_deflate being activated):


<Location />
# (1) Insert filter
SetOutputFilter DEFLATE

# (2) Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# (3) Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4.0[678] no-gzip

# (4) MSIE masquerades as Netscape, but it is fine
# BrowserMatch bMSIE !no-gzip !gzip-only-text/html

# (5) NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html

# (6) Don’t compress images
SetEnvIfNoCase Request_URI
.(?:gif|jpe?g|png)$ no-gzip dont-vary

# (7) Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>

What is it doing? The first line is the most important one. It activates the compression of the data before it is returned by the webserver. Then 2-5 are pretty much neglectable, as they deal with legacy Netscpae browsers and apache bugs. Number 6 is important, as you do not want to recompress already compressed data. The last configuration (7) requires the mod_headers module and deals with proxy caching.

Leave a comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.