Last Updated: February 25, 2016
·
908
· yanhaoyang

nginx configuration for Rails page caching

server {
  listen       80;
  server_name  [domain name];

  root   [Rails root]/public;

  location @passenger {
    passenger_enabled on;
    passenger_app_env production;
  }

  location / {
    error_page 418 = @passenger; return 418;
  }

  location ~ ^/assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
    add_header ETag "";
    add_header Last-Modified "";
  }

  location ~ ^/[path]/? {
    try_files $uri /system/$uri.html @passenger;
    gzip_static on;
    expires max;
    add_header Cache-Control public;
    add_header ETag "";
    add_header Last-Modified "";
  }
}