himanshu saxena
2014-May-29 08:22 UTC
Browser Caching with Rails 4.0.2 with Nginx and unicorn
I am facing an issue with rails application deployed on Amazon with nginx
and unicorn. I am not using any controller or action to render a view,
rather I am using a simple html page inside a sub folder of public folder
named html_app. And all the css, js and images are kept inside that
html_app folder with the same name. see below:
public/html_app/js/test.js
public/html_app/css/test.css
public/html_app/img/test.png
public/html_app/index.html
In order to use browser caching, I have given below configuration for nginx
in config/nginx.conf, see below:
upstream unicorn {
server unix:/tmp/unicorn.cache_app.sock fail_timeout=0;
}
server {
listen 80;
server_name x.x.x.x;
root /home/ec2-user/cache_app/public;
# location ^~ /home/ec2-user/cache_app/public {
# gzip_static on;
# expires max;
# add_header Cache-Control public;
# }
location ^~ /.(jpg|jpeg|gif|css|png|js|ico)/ {
# gzip_static on;
expires 1d;
# add_header Cache-Control public;
# add_header Last-Modified "";
# add_header ETag on;
# break;
}
try_files $uri/index.html $uri @unicorn <https://github.com/unicorn>;
location @unicorn <https://github.com/unicorn> {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
Everything is working except, expires in location block, if I define
expires globally, it works, but not inside the location.
Please suggest, where am I wrong ?
Thanks
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/1a4eacf7-d9e3-433b-8c0c-167c26055d39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.