# Mod\_ruby + mod\_deflate

**URL:** <https://www.ruby-forum.com/t/mod-ruby-mod-deflate/110967>\
**Category:** Ruby\
**Created:** [August 1, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/mod-ruby-mod-deflate/110967 "2007-08-01T15:56:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salvatore\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e274bd/32.png) [@Salvatore\_S](https://www.ruby-forum.com/u/Salvatore_S)\
**Post date:** [August 1, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/mod-ruby-mod-deflate/110967/1 "2007-08-01T15:56:32Z")

</div>

Hello!

I’m running an application written in Ruby using mod\_ruby wtih Apache,  
the application is pretty fast and responsive but output compression  
via mod\_deflate may help to bring even more speed and save bandwidth.

The problem is that it appears to be very hard to make mod\_ruby and  
mod\_deflate to play well together.

This is my simple mod\_deflate configuration:

 AddOutputFilterByType DEFLATE text/html text/plain text/xml

Indeed I’m generating text/html from mod\_ruby.

Still it does not compress at all, while in the same box  
output from PHP scripts are compressed without problems.

I tried to load the deflate module as last module but still  
it does not work.

Somebody aware of the black magic required to make this working?

Thank you very much for your help,  
Salvatore

---

<div class="post-metadata">

**Author:** ![Salvatore\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e274bd/32.png) [@Salvatore\_S](https://www.ruby-forum.com/u/Salvatore_S)\
**Post date:** [August 1, 2007, 6:44pm UTC](https://www.ruby-forum.com/t/mod-ruby-mod-deflate/110967/2 "2007-08-01T18:44:53Z")

</div>

On 01/08/07, Salvatore S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> AddOutputFilterByType DEFLATE text/html text/plain text/xml
> 
> Indeed I’m generating text/html from mod\_ruby.

That’s fine, but apache may not know that. First, get rid of the  
IfModule lines, they just serve to make debugging problems like this  
harder (because it could be that you don’t have the module loaded).  
And then, check how you’re telling apache to pass the request on to  
mod\_ruby. If it’s with AddType, replace that with AddHandler, and use  
AddType to tell apache that the mime-type of your handler is  
text/html. If that doesn’t help, reply (to me directly too please, I  
find this list hard to keep up with) with your apache config and I’ll  
see if I can reproduce the issue.

---

<div class="post-metadata">

**Author:** ![Salvatore\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e274bd/32.png) [@Salvatore\_S](https://www.ruby-forum.com/u/Salvatore_S)\
**Post date:** [August 3, 2007, 3:45am UTC](https://www.ruby-forum.com/t/mod-ruby-mod-deflate/110967/3 "2007-08-03T03:45:45Z")

</div>

On Aug 1, 6:43 pm, “Vincent Bray” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Indeed I’m generating text/html frommod\_ruby.
> 
> That’s fine, but apache may not know that. First, get rid of the

Ok Thanks, actually adding the line:

AddType text/html .rhtml

to my existing configuration solved the issue, now the  
pages are compressed correctly.

The only _virtual_ problem with this is that if I want  
to generate images or other content it’s not worth  
to compress from Ruby this may be compressed anyway  
but I solved the issue using .rb files to generate  
this kind of content while using .rhtml files only when  
the output is really HTML, so everything is fine.

Thanks again,  
Cheers,  
Salvatore
