Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed the steps described in the blogpost The Asset Pipeline, from development to production and tweaked them to my environment. The two important files are:


<VirtualHost *:80>
    DocumentRoot "/var/www/sites/"
    ErrorLog "/var/log/apache2/"
    CustomLog "/var/log/apache2/" common
    <Directory "/var/www/sites/">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    <Directory "/var/www/sites/">
        AllowOverride All
    <LocationMatch "^/assets/.*$">
        Header unset Last-Modified
        Header unset ETag
        FileETag none
        ExpiresActive On
        ExpiresDefault "access plus 1 year"
    RewriteEngine On
    # Remove the www
    RewriteCond %{HTTP_HOST} ^$ [NC]
    RewriteRule ^(.*)$$1 [R=301,L]


RewriteEngine on
RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.+) $1.gz [L]

<FilesMatch \.css\.gz$>
  ForceType text/css
  Header set Content-Encoding gzip

<FilesMatch \.js\.gz$>
  ForceType text/javascript
  Header set Content-Encoding gzip

But apache seems to send empty gzip files because the testsite looses all styles and firebug doesnt find any content for the css files. Altough if I call the assets-path directly I get some gibberish that looks like binary data. If I move the htaccess-file everything is back to normal. How could I find out where/what went wrong or do you have any suggestions what error I made?

> apache2 -v
System: Server version: Apache/2.2.14 (Ubuntu)
Server built:   Mar  5 2012 16:42:17
> uname -a
Linux node0 2.6.18-028stab094.3 #1 SMP Thu Sep 22 12:47:37 MSD 2011 x86_64 GNU/Linux
share|improve this question
up vote 1 down vote accepted

Change the encoding:

<IfModule mod_mime.c>
 AddEncoding gzip .gz

Please do check this blog entry for a more detailed explanation.

share|improve this answer
Steve you are my hero, your answer did't do the trick but the provided link did. If I add the AddEncoding gzip .gz to the end of my .htaccess it works! – wintersolutions Jul 4 '12 at 14:00
@PizzaPill then you should accept the answer and give the bounty! – Pierre Carrier Jul 5 '12 at 13:44
@PierreCarrier you are right, I was waiting for the answer to be updated – wintersolutions Jul 5 '12 at 13:53
AddEncoding is indeed part of mod_mime.c (see ), so the original solution should work? – Pierre Carrier Jul 5 '12 at 15:51

Your Answer


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.