Mephisto Caching with Nginx/Passenger

Now that I had this test bed for new hotness running the new hotness, I decided I should get the caching working again.

Well, this is 2.0 of the code. This seems to work a lot better (like, works in general).

server {

  listen  80;
  server_name  some_spiffy_name;
  root /wheremyappis/public;

  access_log /somelogfile.access.log main;
  error_log /someotherlog.error.log notice;
  client_max_body_size  50M;
  passenger_enabled on;

   location /assets/ {
        rewrite ^/assets/(.*)$ /assets/$http_host/$1 break;
   }

   location /cache/ {
        rewrite ^/cache/(.*)$ /cache/$http_host$1 break;
   }

}

And, as an added bonus, it’s much easier to read!

Thanks to mibb in IRC, we were able to hack the following out:

server {

  listen  80;
  server_name d;
  access_log ;
  error_log ;

  root ;
  passenger_enabled on;

location /assets/ {
  rewrite ^/assets/(.*)$ /assets/$http_host/$1 break;
}

# this appears to be broken
# / -> index.html
#  if (-f $document_root/cache/$host$uri/index.html) {
#    rewrite (.*) /cache/$host$1/index.html break;
#  }

# /about -> /about.html
  if (-f $document_root/cache/$host$uri.html) {
    rewrite (.*) /cache/$host$1.html break;
  }

# other files
  if (-f $document_root/cache/$host$uri) {
    rewrite (.*) /cache/$host$1 break;
  }

}

2 thoughts on “Mephisto Caching with Nginx/Passenger”

  1. I have

    sendfile on;

    tcp_nopush on;

    gzip on;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_buffers 16 8k;
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    in my nginx.conf. It rocks!

  2. using following technic for the speed loading improvement

    nginx.conf:
    gzip on;
    gzip_comp_level 8;
    gzip_proxied any;
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml
    application/xml+rss text/javascript;

Leave a Reply