PHP 包含和加载时间

发布于 2024-11-30 00:12:23 字数 643 浏览 1 评论 0原文

如果我将 PHP 添加到页面中。

include('example.php')
- It then has to load that file which would / could slow down load time correct? Right now I am making unnecessary redirects back to the a login page if the logins are wrong via javascript snippet that is inside my login.php page (which does all the login checking against the database). So in the address bar it shows "admin.php > login.php > admin.php" , but I don't ever want to show what file it is going to in order to test the logins, but I also do not want to include this inside admin.php because I'm afraid it might affect load time.

如果您理解我的问题,那么建议将会有所帮助。

If I add PHP includes to a page.

include('example.php')

- It then has to load that file which would / could slow down load time correct? Right now I am making unnecessary redirects back to the a login page if the logins are wrong via javascript snippet that is inside my login.php page (which does all the login checking against the database). So in the address bar it shows "admin.php > login.php > admin.php" , but I don't ever want to show what file it is going to in order to test the logins, but I also do not want to include this inside admin.php because I'm afraid it might affect load time.

If you understand my question then suggestions would be helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不羁少年 2024-12-07 00:12:23

就服务器端的可读性和可维护性而言,做您认为最好的事情。然后,如果您遇到性能问题,请通过测量(而不是猜测)找到问题的根源,并尝试优化。

你过早地进行优化,这是万恶之源。与执行 HTTP 请求/响应所需的时间相比,包括一些额外的 PHP 行肯定可以忽略不计。

Do what you feel is best in terms of readability and maintainability at server-side. Then, if you have a performance problem, find where it comes from by measuring (and not guessing), and try to optimize.

You're optimizing prematurely, and this is the root of all evil. Compared to the time it takes to a HTTP request/response to execute, including some additional lines of PHP is very certainly negligible.

渡你暖光 2024-12-07 00:12:23

新的 HTTP 请求(重定向)总是比包含请求对性能造成更大的影响,因此如果您只关心性能,则没有理由使用重定向(尤其是 Javascript 请求)。因此,如果我理解您的意思,我想建议您只包含该文件。

New HTTP requests (redirects) are always a bigger performance hit than includes, so there's no reason to use redirects (especially Javascript ones) if you're only concerned about the performance. So if I understand you I'd like to suggest that you just include the file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文