Getting mod_deflate working on Apache for a PHP app on Heroku's Cedar stack

969 Views Asked by At

How can I get mod_deflate on Apache and Heroku Cedar with a PHP app? I have mod_deflate importing and rules set set in my htaccess, yet my responses won't gzip.

1

There are 1 best solutions below

0
On

Not sure if you're still interested in solving this problem, but here goes. A lot of this is going to depend on how you've set your dyno up.

If you're running the Heroku PHP buildpack with Apache, the buildpack version of Apache comes with mod_deflate pre-installed.

Even if you're not running the Heroku PHP buildpack, there's some chance that mod_deflate might be pre-installed. You can check by running a bash prompt on a one-off dyno and using apache2ctl to list all available modules:

$ heroku run bash
Running `bash` attached to terminal... up, run.9057

$ $(which apache2ctl || which apachectl) -M
Loaded Modules:  
  core_module (static)  
  ...  
  deflate_module (shared)  
  ...

After ensuring that mod_deflate was installed and enabled, I then used the .htacess configuration recommended by html5-boilerplate to compress textual MIME types. I added this config to my apache config, but I would think it would work from .htaccess too. After deploying the new configuration, mod_deflate worked as expected.

Hope this helps!