Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Would a website load faster using PHP includes, or by hard coding them into the pages themselves?
I would primarily use the PHP for the header and footer, using this statement:
<?php require("header.php") ?>
No, including files won't have any negative performance impact that's significant at all. This is an example of Premature Optimization.
When you're running PHP code in Production, you should be using an OpCode Cache, like the Zend OpCode Cache built in to PHP 5.6+. In such a cached setting, there is literally no difference whatsoever. Even uncached, the difference will never be noticeable. You will have much more low-hanging fruit to optimize.
As far as webpage load times, this will especially not be noticeable at all. The HTTP request itself will be the "slow" part.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Do WordPress Page Builders increase page load speed and as such, should these be avoided by those competent at hard coding?
Or is there something else that I am missing as the only real value, I can see with Page Builders, is that they help reduce time spent on coding.
Use code. Page builders add additional load time. Your site may also become less portable and maintainable because a bulk of the design for your site could be stored in the database. It really depends on the situation. I would assume code to be a little cleaner though.
Page builders add additional code which are mostly unnecessary so it means the page is heavier and therefore the speed is lower, i would recommend to always make the code by a coder, but if the page just have little content then probably a page builder cold come in handy
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm currently optimizing an application's login process' caching and I'm thinking of using a File based approach, but I'm not so sure if it's the best when it comes to speeding things up. So among the following approach, which would greatly improve my application?
PHP_SESSION
Filebased(physical file)
PDO_Database
FTP
Anything that touches files is less optimal for caching than when staying in memory. Respectively anything that goes via a network is generally even slower. So when it comes to speed you're probably best off using the PHP_SESSION.
Do note however that because it is memory based you also lose the cache when the application or the server is restarted. If this is undesired you should probably go for a file based solution.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm trying to optimise PHP code to manage code easily and to speedup page execution time. My strategy is to create a file core_functions.php and defined all functions in this file. Then include this file into every other file of the project.
I need to know is it best practice to have all function defined in one file or it is best practice to split the function into different files and include where needed.
What you're doing is actually going to hurt performance. In each page that loads the 6000 line file the PHP interpreter has to interpret that whole file. You'd be better of splitting your functions into modules and have each page only reference the modules it needs.
This reinterpretation of PHP files on each page load can be reduced though by using a caching mechanism that caches the compiled byte code of interpreted files.
There is a list of frameworks that do this here: http://en.wikipedia.org/wiki/List_of_PHP_accelerators
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm kinda new to PHP and I am writing a new script, so I have a general wondering.. Is it okay to have a large PHP file? Or I should just split it? By large I mean 3000 Lines <
Everything is working fine, I just want to know if this may affect the response time or something..
There is no problem with large PHP file. But if you want to divide your code in separate files this will help you in fixing the bug and in code reusability.
It will not affect in response time or performance of your code.
Splitting the file will not help, because presumably you'd just be loading the code from multiple files instead of one file.
In fact, it has been shown that performance gets significantly better if you append files together instead of forcing the PHP request to load a lot of individual PHP code files.
If you are at all concerned with performance, you should be using a PHP bytecode cache.
In any case it will have the best response time with the given code since it will need to read that one file only.
The problem with having a single monolithic file is it will make it harder to maintain
try to improve reusabilty and readability of your code. There are no rules about the lenght of your code.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have stored all my necessary functions to a file functions.php.inc and I use this at the top of each page like this
require_once("functions.php.inc");
I want to know that Is there any effect on performance to have this name. If I change the functions.php.inc to functions.php will it give better performance or there is no any difference.
Besides the .inc warning given in comments, there should be no performance impact (extra 4 characters comparison, negligible ; the file system also is very comfortable with having to deal with a 13 or 17 chars file name).
Also, in recent versions of PHP, the APC cache is included (default), meaning that there is no extra parsing of the file that require that inc file (just the first time it is accessed). Then APC checks the file status (from file system) to detect a change when it is accessed again, from further requests.