Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable compression in a PHP app on heroku?

I am running HTML5 Boilerplate compression in my .htaccess file on a heroku app. However, it doesn't seem to be working and none of the files are actually being compressed.

I added the heroku php buildpack with:

heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php

but that didn't seem to do anything. I'm pretty new to Heroku so does anyone have any advice?

HTML5 Boilerplate htaccess code:

# Force compression for mangled headers.
# http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
<IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
        SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
        RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    </IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
#  and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
#  as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE application/atom+xml \
                                  application/javascript \
                                  application/json \
                                  application/rss+xml \
                                  application/vnd.ms-fontobject \
                                  application/x-font-ttf \
                                  application/x-web-app-manifest+json \
                                  application/xhtml+xml \
                                  application/xml \
                                  font/opentype \
                                  image/svg+xml \
                                  image/x-icon \
                                  text/css \
                                  text/html \
                                  text/plain \
                                  text/x-component \
                                  text/xml
</IfModule>

like image 261
Quinton Aiken Avatar asked Nov 02 '13 20:11

Quinton Aiken


1 Answers

I found that using a different buildpack worked!

heroku config:set BUILDPACK_URL=http://github.com/iphoting/heroku-buildpack-php-tyler

This is a wonderful buildpack that enables gzip compression and installs new-relic.

like image 138
Quinton Aiken Avatar answered Oct 24 '22 04:10

Quinton Aiken