httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <>
Subject Re: [users@httpd] Serving pre-compressed static content using httpd 2.2.x
Date Mon, 09 Apr 2012 14:08:43 GMT
Hi Chris,

On 28.03.2012 23:10, Christopher Schultz wrote:
> All,
> Replying to see if I can get a response. Anyone?
> Thanks,
> -chris
> On 3/22/12 3:10 PM, Christopher Schultz wrote:

>> If I don't use content-negotiation, I can use mod_rewrite to fake it:
>> it's a lot easier to just look for Accept-Encoding and then do an
>> internal redirect to a pre-compressed file, especially since there's no
>> issues with language or other Accept-* headers confusing things.
>> <Directory "/path/to/css/files"
>>    Options +SymLinksIfOwnerMatch
>>    RewriteEngine On
>>    RewriteCond %{HTTP:Accept-Encoding} gzip
>>    RewriteRule test.css$ /path/to/css/files/test.css.gz [E=gz:1]
>>    Header set Content-Encoding gzip env=gz
>> </Directory>
>> This is great because the original file can sit there on the disk and I
>> can provide compressed versions of it to clients who can deal with it.
>> No changing URIs or anything like that.
>> Only problem is that setting the Content-Encoding header doesn't appear
>> to be working. When set unconditionally, it works, but when attempting
>> to use the "gz" environment variable, Content-Encoding doesn't seem to
>> be set.

I'd start debugging this detail problem. I'm pretty sure I got this 
working at least twice. using Apache 2.2.not_too_old.

So first check, whether the "gz" environment variable is actually set. 
For this add %{gz}e (and %{Content-Encoding}o) to your LogFormat. Also 
add a RewriteLog with a high RewriteLogLevel.

Note that I personally didn't use the rules inside a Directory block. I 
also prefer to add the .gz file suffix in front of the originsal suffix, 
so e.g. .gz.css instead of .css.gz, because that way Apache will 
automatically set the Content-Type header correct using the suffix list 
in the mime types file.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message