Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routes.rb vs rack-rewrite vs nginx/apache rewrite rules

I have dozens of rewrite rules for legacy URLs from a previous incarnation of my application. I see three choices:

  1. Just add "match" lines in the routes file (config/routes.rb)
  2. Use rack-rewrite
  3. Create Nginx/Apache rewrite rules (Nginx in my case)

I imagine that 3 has better performance than 2, which has better performance than 1.

My questions:

  • Is that true?
  • If so, how much does it matter?
  • Are there other trade-offs I might not have considered?
  • Any other options altogether besides those three?
like image 703
dreeves Avatar asked Apr 22 '11 15:04

dreeves


1 Answers

  1. Yes, you have the performance order correct.
  2. Depends on your site, the traffic, the number of hits on those rewrite rules - in all likelihood the performance matters a lot less than the maintainability.
  3. Maintainability - use what you know, and what your developers know. Apache's rewrite syntax is easy to get wrong, and tends to be quite Write-Once-Read-Never. Nginx's is quite nice, but still a new DSL for you and your devs to learn. rack-rewrite is the inverse of Apache, it's actually hard to make a mistake because it's so simple (I think it's simpler than routes.rb)
  4. None worth evaluating.
like image 90
smathy Avatar answered Nov 10 '22 04:11

smathy