使用重定向VS重写规则的速度影响 [英] Speed implications of using Redirect vs RewriteRule

查看:183
本文介绍了使用重定向VS重写规则的速度影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,想知道是否有速度的规则集之间的区别,并在在Apache中的.htaccess规则重定向。

I'm curious to know if there is any difference in speed between RewriteRules and Redirect within a .htaccess rule on Apache.

在我看来,规则集往往是复杂的正则表达式EX pressions我假设有开销(即使是小得令人难以置信)相比,重定向,这将是简单的字符串匹配(?)

To my mind, RewriteRules can often be complex regex expressions which I assume have overhead (even if it's incredibly small) compared to Redirect that would be simple string matching(?)

所以,如果我有:

RewriteRule ^mytestpage\.html$ http://www.google.com [R=301, QSA]

VS

Redirect 301 /mytestpage\.html http://www.google.com/

我可能永远不会注意到差别,但如果我有1000独特的重定向?或10,000?难道是adventagous使用一个比其他?

I'm probably never going to notice a difference, but what if I had 1000 unique redirects? or 10,000? Would it be adventagous to use one over the other?

推荐答案

使用或者是可以忽略不计,你不会发现有不同的速度产生影响。话虽这么说,你应该使用合适的工具来完成工作。

The speed implications of using either is negligible and you won't notice a difference. That being said, you should use the right tool for the job.

做一个简单的重定向,你应该使用使用mod_rewrite的重定向代替。这个例子是什么重定向应该照顾。当你需要开始做更复杂的事情,你可以考虑使用mod_rewrite。

Doing a simple redirect, you should use a Redirect instead of using Mod_Rewrite. That example is something a Redirect should take care of. When you need to start doing more complex things you can think about using Mod_Rewrite.

即使1000或10,000重定向你不是真的要注意到一个很大的区别。但是它会使用更多的内存。大概几MB的,如果这一点。

Even with 1000 or 10,000 redirects you're not really going to notice a big difference. However it will use more RAM. Probably a few MB's if that.

因此​​,要回答你的问题,它确实不会产生实质性的影响,但使用正确的工具来完成工作。

So to answer your question, it really wont have a real impact but use the right tool for the job.

这应该有所帮助。

当不使用mod_rewrite

这篇关于使用重定向VS重写规则的速度影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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