enabling gzip with htaccess...why is it hit or miss?

Posted by adam-asdf on Server Fault See other posts from Server Fault or by adam-asdf
Published on 2012-11-12T03:29:50Z Indexed on 2012/11/12 5:02 UTC
Read the original article Hit count: 542

I have shared hosting through Justhost. I use the HTML5 Boilerplate .htaccess (have tried other methods from here and there without luck) the compression part is as follows:

<IfModule mod_deflate.c>

  # Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
  <IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
      SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
      RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    </IfModule>
  </IfModule>

  # Compress all output labeled with one of the following MIME-types
  <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE application/atom+xml \
                                  application/javascript \
                                  application/json \
                                  application/rss+xml \
                                  application/vnd.ms-fontobject \
                                  application/x-font-ttf \
                                  application/xhtml+xml \
                                  application/xml \
                                  font/opentype \
                                  image/svg+xml \
                                  image/x-icon \
                                  text/css \
                                  text/html \
                                  text/plain \
                                  text/x-component \
                                  text/xml
  </IfModule>

</IfModule>

However, it isn't working—at least I don't think—My home page (html) isn't compressing, the CSS and some of the JS aren't gzipped.

It is failing on HTML, CSS and JS.

However, some things are (or were, who knows what it will look like when you check) gzipped.

My domain is http://adaminfinitum.com/

What is weird is that the (Google) PageSpeed browser extension for Firefox (whatever the current version is [Nov. 2012]) gives me a 95% speed rating (and no warnings about compression), yet YSlow and Chrome developer tools both flag me about gzip, as does a tool I found on here while researching this.

To reduce cookies I set up a subdomain on my site and I thought maybe that was it so I added an .htaccess there also, but no luck.

To reduce http requests I embedded some of webfonts and images in CSS (HTML5 BP stipulates not to compress images, and apparently '.woff' files are already compressed) so I thought maybe that was it and I spent all day separating and asynchronously loading those portions (via Modernizr.load) but that hasn't helped either...if anything it made it worse due to increasing http requests (I realize speed scores of async resources may be misleading).

Researching this, it seems to be a fairly common issue but I haven't found an explanation/solution.

I don't think it is a MIME-type issue, I have quadruple checked (and thrice edited) my .htaccess files.

My hosting company said they run Apache 2.2.22 and I have looked at everything I can find.

What gives?

© Server Fault or respective owner

Related posts about apache2

Related posts about gzip