Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GZip Assets #24

Open
paynecodes opened this issue Jan 25, 2014 · 2 comments
Open

GZip Assets #24

paynecodes opened this issue Jan 25, 2014 · 2 comments

Comments

@paynecodes
Copy link

I came across this buildpack mostly due the fact that I wanted to GZip my assets. I figured nginx would be good for this (as well as the reasons listed in your README).

Anyways, I added the default nginx.conf.erb to my config folder. Then I attempted adding the following from the Asset Pipeline Guide to the server section like this:

server {
  ...
  location ~ ^/(assets)/  {
    root /path/to/public;
    gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
  }
}

I get an application error. Here's the most important part from the logs:

nginx: [emerg] unknown directive "gzip_static" in ./config/nginx.conf

Of course, /path/to/public is just placeholder, so, as a side note, I'm wondering if this will work:

root <%= Rails.root.join('public').to_s %>

Moving forward, it seems that nginx needs to be configured with http_gzip_static_module. I'm not exactly sure how to do that or if it fits in the scope of this repo.

Does anyone have any experience with trying to GZip precompiled assets using nginx? Better way? Am I on to something we could merge in with this repo? This module seems to be configurable in other, less popular build packs I've seen around here on GitHub.

Also, this method is documented here using Passenger: http://dennisreimann.de/blog/configuring-nginx-for-the-asset-pipeline/

@diwu1989
Copy link

I had to set the following rules:

http {
        gzip on;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_min_length 512;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml image/svg+xml;

@khoan
Copy link

khoan commented May 28, 2015

looks like --with-http_gzip_static_module wasn't included when compiling nginx binary (see http://nginx.org/en/docs/http/ngx_http_gzip_static_module.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants