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

不打扰是莪最后的温柔 提交于 2019-12-10 13:46:59

问题


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?

回答1:


  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.


来源:https://stackoverflow.com/questions/5756965/routes-rb-vs-rack-rewrite-vs-nginx-apache-rewrite-rules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!