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

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

  • Just add matching lines to your routes file (config / routes.rb)
  • Use rack-rewrite
  • Create Nginx / Apache rewrite rules (Nginx in my case)

I believe 3 has better performance than 2, which has better performance than 1.

My questions:

  • It's true?
  • If so, how much does it matter?
  • Are there any other tradeoffs that I may not have considered?
  • Any other options in general besides these three?
+4
source share
1 answer
  • Yes, you have the correct execution order.
  • Depends on your site, traffic, the number of calls to these rewriting rules - in all likelihood, performance is much less than maintainability.
  • Maintaining health - use what you know and what your developers know. The Apache rewrite syntax is easily mistaken and is usually “Write-Once-Read-Never”. Nginx is pretty nice, but still a new DSL for you and your developers. rack-rewrite is an inverse of Apache, it’s actually hard to make a mistake, because it is so simple (I think it is easier than routes.rb )
  • Do not evaluate.
+8
source

All Articles