[Mongrel] #17446 [PATCH] Add option to mongrel_rails to force mongrel not to serve static files
saimonmoore at gmail.com
Thu Jan 24 21:21:53 EST 2008
The problem is that mongrel is serving the static file long before
rails knows anything about it.
e.g. As I mention in the patch, you have a web server setup with
multiple virtual hosts each mapped to a separate doc root.
example.com => /var/www/apps/example.com/public
es.example.com => /var/www/apps/example.com/public/es
Rails is using page caching and the cache is clean.
1. web server looks for /var/www/apps/example.com/public/index.html
2. passes request to mongrel which does the same thing, doesn't find
it and calls rails to render it.
3. Now /var/www/apps/example.com/public/index.html exists as was
cached by rails.
1. web server looks for /var/www/apps/example.com/public/es/index.html
2. passes request to mongrel which looks for /var/www/apps/example.com/
(which unlike the web server, has only one doc root),
finds the file under /var/www/apps/example.com/public/index.html
(from the previous request) and serves that back before rails has even
got a chance to know about it. It has served the wrong file.
I hope this example makes it clearer.
With the ability to force mongrel to forward all requests it receives
to rails, on the second request rails (using the host info) would then
cache the index.html file into /var/www/apps/example.com/public/es/
As I was writing this, I just thought of another possibility being
writing a custom mongrel handler, but as mongrel_rails is a handler
itself, it seems a bit pointless so I still think my patch has merits.
On Jan 24, 2008, at 4:42 PM, Nathan Vack wrote:
> On Jan 24, 2008, at 6:13 AM, Saimon Moore wrote:
>> Hi all,
>> I've just added a patch that I'd appreciate some feedback on:
> I'll admit by cold-addled brain isn't following logic perfectly this
> morning, but I feel like this really would be better handled by the
> upstream HTTP handler giving enough information to your app so it
> serves the right cached file (or runs the right controller, or
> I think passing the Host: header along with the request_routing
> plugin (assuming you're on Rails) will make everything happy:
> Or am I missing something?
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
Freelance Web Developer
(Available for hire - For details visit http://saimonmoore.net)
Yahoo IM: saimonmoore
Google IM: saimonmoore
More information about the Mongrel-users