Nauhaie None
2006-Aug-31 16:36 UTC
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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Rick Olson
2006-Aug-31 21:06 UTC
Re: REST + Caching + Apache 2.2 Rewrite problem and solution?
> 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? >Does it work? Seems like it should. Mongrel has something similar built in actually (not that it''ll help in this case). -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---