开发者

PHP Includes and Load Time

开发者 https://www.devze.com 2023-03-28 19:50 出处:网络
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 l开

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 l开发者_StackOverflowogin 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消