I have enabled apache served files compression in the .htaccess of my website. However when I check with Google PageSpeed if it's working or not I get "Enable Compression" as a high priority. Also the website doesn't feel faster.

I have enabled compression in the .htaccess:

php_flag zlib.output_compression on

And I have uncommented the lines:

# Insert filter on all content
SetOutputFilter DEFLATE

# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

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

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

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

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

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

Am I doing this right? Why isn't the Website loading faster?

1 Answer 1


To test this, run a check on the site using http://tools.pingdom.com. Clicking the little arrow next to the document request in the waterfall will show you the full request/response headers.

If the compression is setup correctly on the server, this will load the gzip'd content. You can tell if it's loading compressed content by looking at the Content-Encoding header in the response. It should read gzip if it's compressed. The Accept-Encoding in the request should also include gzip in the list, or the server won't send gzip.

In your .htaccess settings, you should disable the following rule:

# Insert filter on all content
SetOutputFilter DEFLATE

If anything other than text based content is served up by the web-server, this will compress and possibly double-compress assets. The compression for text based content is enabled based on the mime-type in the AddOutputFilterByType rule just beneath this one.

If you have the Varnish page cache in front of the website, these rules won't mean anything for final delivery since Varnish will be serving up the final request and would have to be configured correctly to handle the compressed content.

Another thing to check is that mod_deflate is installed and working in Apache. The zlib rule you show in the question doesn't affect the rules in .htaccess. It's a different method of compressing output entirely. The .htaccess rules mean Apache compresses stuff it sends out, the zlib rule would have PHP compress the response before it passes it off to Apache for delivery.

You may even try disabling that zlib rule in your ini file. I'm not certain, but it may very well interfere with Apache compressing stuff since it will change the mime-type of the content which is put out.

  • Hi @davidalger - I have checked with Pingdom and it certainly says its using GZIP, so I take it's compressing but I guess the difference isn't that apparent to me. May 30, 2013 at 21:05
  • @EdgarQuintero - Since what gzip compression does is reduce the amount of data that is transferred, the visible effect will be very little on fast connections. Where it creates the most benefit is slow connects such as slow 3G/Edge cellular networks and dialup. For fast connections, it's not uncommon to have more time spent connecting (latency) than transferring HTML. For your HTML document, the most important thing is minimizing the "wait" time, i.e. time it takes the server to generate the page.
    – davidalger
    May 31, 2013 at 13:40
  • Glad to hear it's working! :)
    – davidalger
    May 31, 2013 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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