Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

/etc/apache/site-available/example.com

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

/var/www/sites/example.com/shared/assets/.htaccess

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>

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

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

1 Answer 1

up vote 1 down vote accepted
+50

Change the encoding:

<IfModule mod_mime.c>
 AddEncoding gzip .gz
</IfModule>

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

share|improve this answer
1  
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 httpd.apache.org/docs/2.0/mod/mod_mime.html ), so the original solution should work? –  Pierre Carrier Jul 5 '12 at 15:51

Your Answer

 
discard

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.