Consoles
 

Posts Tagged ‘caching’

Advanced Page Caching Hacks in NGINX

by Jason LaPorte, June 26th, 2009 at 01:59pm - No Comments »
Tagged As: , ,
Posted in: Bending Rails, Engineering, Infrastructure

Those of you in the Rails community who use NGINX may have come across this before: Ezra Zygmuntowicz’s NGINX config. It bears some similarity to the ones we use at Agora. Specifically, the section relating to serving page-cached files. The relevant lines (pulled from one of our configs) looks like this:

if (-f $request_filename.html) { rewrite (.*) $1.html break; }
if (-f $request_filename/index.html) { rewrite (.*) $1/index.html break; }
if (!-f $request_filename) { proxy_pass http://some-proxy; }

This generally works well, for simple cases. Unfortunately, we’ve run into some more complex ones where it didn’t cut it. I’ll outline two of those cases below and show what we did to fix it.

(more…)