使用重定向VS重写规则的速度影响

编程入门 行业动态 更新时间:2024-10-25 12:29:14
本文介绍了使用重定向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$ www.google [R=301, QSA]

VS

Redirect 301 /mytestpage\.html www.google/

我可能永远不会注意到差别,但如果我有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重写规则的速度影响

本文发布于:2023-11-01 23:03:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550663.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   重定向   规则   速度

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!