Routes.rb vs机架重写vs nginx/apache重写规则 [英] Routes.rb vs rack-rewrite vs nginx/apache rewrite rules

查看:40
本文介绍了Routes.rb vs机架重写vs nginx/apache重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几十个针对旧URL的重写规则,这些规则来自于我的应用程序的前身. 我看到三个选择:

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

  1. 只需在路由文件(config/routes.rb)中添加匹配"行
  2. 使用机架重写
  3. 创建Nginx/Apache重写规则(在我的情况下为Nginx)

我想3的性能要比2的性能好,而2的性能要好于1.

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

我的问题:

  • 是真的吗?
  • 如果是这样,有什么关系?
  • 还有我可能没有考虑过的其他折衷方案吗?
  • 除了这三个以外,还有其他选择吗?

推荐答案

  1. 是的,您的表演顺序正确无误.
  2. 取决于您的站点,流量,这些重写规则的点击次数-性能很可能远不及可维护性重要.
  3. 可维护性-使用您所知道的以及开发人员所知道的. Apache的重写语法很容易出错,并且往往是 Write-Once-Read-Never . Nginx的挺不错,但仍然是您和开发人员学习的新DSL. rack-rewrite与Apache相反,实际上很难犯一个错误,因为它是如此简单(我认为它比routes.rb更简单)
  4. 一个都不值得评估的人.
  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.

这篇关于Routes.rb vs机架重写vs nginx/apache重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆