Passenger and conditional page caching

Dreamhost recently made Passenger available for running Rails applications. I switched over Exchange Rates and it appears to work fine.

Giggle does not work properly when switched over to Passenger though. The problem is that my caching setup relies on a custom rewrite rule, but Passenger disables use of mod_rewrite for web applications it runs. It does this because the usual rewrites in Rails applications are to deal with page caching and forwarding requests to Rails, and Passenger has its own implementation of that part – but in my case, that is exactly what the rewrite rule was trying to change. It’s fairly clear that I can’t make my conditional page caching work in the same way under Passenger (unless I change Passenger itself).

I have thought of a possible workaround. I haven’t tested this yet though. There is a setting for Passenger to re-enable rewrite rules – it just won’t get on with ones that try to do what Passenger is doing itself. So the idea is to write a rewrite rule that will add a path segment to the URL when the logged_in cookie is present. This will then get passed through to Rails, and it will have an extra line in routes.rb to make the ‘logged in’ URL have the same effect.

e.g.
http://giggle.ethelred.org/bands/47
with logged_in cookie will get rewritten as
http://giggle.ethelred.org/loggedin/bands/47

Then Rails needs to treat both URLs the same – I need to figure out how to do that, and how to test this setup.

One Trackback

  1. […] A while back I posted about Passenger and how it could affect my Giggle website. […]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*