caching static files for ruby on rails application using nginx

Posted by splintercell on Stack Overflow See other posts from Stack Overflow or by splintercell
Published on 2010-04-02T12:30:58Z Indexed on 2010/04/02 12:33 UTC
Read the original article Hit count: 283

I have been trying for some time to serve & cache static files for my rails app using nginx. the rails app server runs mongrel_cluster and is deployed on a different host than that of nginx.

following many of the available discussions I tried the following

server {

     listen       80;

     server_name  www.myappserver.com;



     ssl on;

     root /var/apps/myapp/current/public;



     location ~ ^/(images|javascripts|stylesheets)/ {

            root /var/apps/myapp/current;

            expires 10y;

                                                    }



     location / {

                    proxy_pass http://myapp_upstream;

                }

                  }

But nginx fails to find the images and to load the css and js files. Can anyone help me out here?

My aim is to configure nginx in such a way that it caches the static files till expiry.

Please suggest me some way to achieve this or am I missing any point here?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about nginx