[英]Does moving out of directory to the .htaccess file increase the CPU load time and CPU cycle
I have many hyperlinks like this: This link is placed in interact folder and links to the main folder. 我有很多这样的超链接:此链接放在交互文件夹中,并链接到主文件夹。
<a href='../user/" . $id . "/".$name."' target='_self'>" . $name. "</a>
Which goes back to the main directory of the website and in the main directory there is a .htaccess
file with this code 返回到网站的主目录,在主目录中有一个带有此代码的
.htaccess
文件
RewriteRule ^user/([0-9]*) interact/profile1.php?id=$1 [L,QSA]
I have done this to make URL look like: 我这样做是为了使URL看起来像:
http://www.domain.com/user/
Instead of this: 而不是这个:
http://www.domain.com/interact/user
This makes the request return to the same directory it came from that is the /interact directory. 这使得请求返回到它来自/ interaction目录的同一目录。 I have many hyperlinks that do something like this.
我有很多超链接可以做这样的事情。 Will having many such hyperlinks increase the CPU load time ?
有很多这样的超链接会增加CPU加载时间吗?
Yes, using rewriting uses more CPU. 是的,使用重写使用更多的CPU。 But it does not depend on the number of links, it depends on the number of requests done.
但它不依赖于链接的数量,它取决于完成的请求数量。
And additionally, using a .htaccess file also impacts performance. 此外,使用.htaccess文件也会影响性能。 A lot more than rewriting.
不仅仅是重写。
Rewriting inside .htaccess has a double impact, because evaluating the .htaccess file takes place relatively late in the process, and a rewrite there basically starts the whole process all over. 重写.htaccess会产生双重影响,因为评估.htaccess文件的过程相对较晚,并且重写基本上会在整个过程中开始。
On the other hand the impact is measurable, but rarely noticeable on the average server. 另一方面,影响是可测量的,但在普通服务器上很少引人注意。 Are you in a high traffic situation?
你是否处于高流量的情况? Then I'd suggest getting rid of the .htaccess files altogether, disabling them in the Apache configuration, and putting the rewriting rule into the vhost configuration.
然后我建议完全删除.htaccess文件,在Apache配置中禁用它们,并将重写规则放入vhost配置中。
Residing there, they only have to be parsed when the server starts, and you avoid that the server constantly has to look for a .htaccess file in any directory that might be touched by a request. 驻留在那里,只需要在服务器启动时解析它们,并且避免服务器不断地在任何可能被请求触及的目录中查找.htaccess文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.