REST + Caching + Apache 2.2 Rewrite problem and solution?

Hi,

A lot of us are now using Apache 2.2 + mod_rewrite to forward incoming
and uncached requests to a Mongrel Cluster.

That was fine until REST arrived.

With the current recommended configuration, Apache works as follows:

a. There is a static file avaliable in the file system => send it
(regardless to the request method)
b. There is none, forward request to Mongrel Cluster

However, with RESTful Rails, we have urls such as /articles/1 which
should be cached only when we GET it, not when we POST or PUT it. What
if we want to update an article and Apache sends us the static HTML file
instead of forwarding our request to Rails?

Here is the solution I suggest:

Replace in apache configuration file:

Redirect all non-static requests to cluster

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://MyCluster%{REQUEST_URI} [P,QSA,L]

By

Redirect all non-static requests to cluster

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_METHOD} !^GET*
RewriteRule ^/(.*)$ balancer://MyCluster%{REQUEST_URI} [P,QSA,L]

What do you thing about that?

RewriteCond %{REQUEST_METHOD} !^GET*
RewriteRule ^/(.*)$ balancer://MyCluster%{REQUEST_URI} [P,QSA,L]

What do you thing about that?

Does it work? Seems like it should. Mongrel has something similar
built in actually (not that it’ll help in this case).


Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com

Yes it should work. But I am looking for people who know more than I do
about Apache and REST to confirm that this is or is not a good idea…

Someone?

I spent loooong time to locate the problem, and then your solution
saved me from wasting more. Thanks a lot.

On Sep 1 2006, 12:36 am, Nauhaie N. <rails-mailing-l…@andreas-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs