Rails, Page Caching, Lighttpd and Stupidity

I thought I would pass on the trouble (and solution) I ran into this past week trying to understand why Rails page caching was just not working for me. I run this blog and pervwatch.org on TextDrive. The recommended and typical setup for Rails is to run with lighttpd, proxied by Apache. I managed to get the site operating fine with this setup but for whatever reason page caching simply didn't work.

I forgot about it, until some of the pages became slow to load due to large amounts of DB queries (particularly my rails generated sitemap for pervwatch.org). It became a big nuisance for the sites to laod so slowly when they were both easy and amenable to full page caching. I played around with my lighttpd config and posted pleas for help to the textdrive forum, support, and rails mailing list to no avail. The problem? Two swapped characters.

The wrong way

url.rewrite = ( 
  "^/$" => "index.html", 
  "^([^.]+)$" => "1$.html"
)

The right way

url.rewrite = ( 
  "^/$" => "index.html", 
  "^([^.]+)$" => "$1.html"
)

About this entry

Advertise here!