Click here to Skip to main content
16,017,297 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My PHP Application's index page is taking more than 30 secs to load. I am using PHP version - 8.1.18 on RHEL 8.6 and Apache v2.4.4
The index.php page contains 43 javascripts included through the <script> tag. These js files call a portal.php file which includes 15 other php files using include_once. One of the included file is responsible for database connection. The portal.php file contains a parametrized switch case which calls one or multiple included php files. A total of 27 requests are been simulataneously made through the javascript files to portal.php and the response is fetched. My observation is the response from portal.php is taking a lot of time to respond which in turn results in the performance issue.  

Please advise on how to increase performance of my index.php page.


What I have tried:

Until now I have tried:
Optimizing and minification of all js files.
Installed opCache.
Checked all the database queries whether they are taking time to load which is not happening.
defer and async for javascript loading

None of the above has worked. 
Posted
Updated 2-May-23 16:03pm
Comments
Richard MacCutchan 2-May-23 10:11am    
You need to do some debugging to find a) where the slow repsonses are occurring, and b) what is the cause of them. That is not something that anyone here can do for you. But looking at the description in your question I suspect it is a simple matter of far too much processing on that page.
Ganesh Naidu 2023 2-May-23 12:06pm    
Okay, Thank you
[no name] 2-May-23 12:30pm    
make the best you can to publish piece of code
if you have doubt on few code section.
Taking note about the lot of files involved, try to show here few suspicious low loading code please !
[no name] 2-May-23 12:46pm    
as Php have a delay when you use include() in a switch/case

use require_once(); for all the files needed for all needs.
and write them at top of your php scope. ( instead of a dispatch of 'include_once' every where.

require_once() avoid a file to be loaded several times.
it's an optimisation about include() and include_once()

<?php // top of your php script

  require_once('file_1.ext');
  require_once('file_2.ext');
  require_once('file_3.ext');
  require_once('file_4.ext');
 
// and after , put your processing code.

1 solution

Check your time to first byte in your browser debugger
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900