Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

Reducing Server Response Time

I get an A grade on staging server and a C on production server which is weird (It is the same code):

On production I have a: reduce initial server response time

which has a High Impact

https://gtmetrix.com/reduce-initial-server-response-time.html

  1. Optimizing your application code (including database queries)

The Application code is crucial to web performance optimization.

We strongly recommend that you solicit developer assistance as you are now dealing with the core logic of your website.

When you engage in code profiling, some of the optimizations include:

  1. Streamlining the codebase, making functions more efficient
  2. Reducing complex operations or bundling up code to be only executed when needed
  3. Making database queries more efficient, removing unnecessary queries

I don't understand point 1 - 3. Does it means removing unnecessary code ? I have some codes that I commented out since my klien canceling a feature that I already build. So there are many comments.

What about Repo functions that the program does not called out - does it count (I actually don't have one at this point of time since I build a new repo) ?

0 likes
18 replies
Sinnbeck's avatar

Open the page locally and check debugbar. How many queries are run, and how many models are hydrated?

Is the data on the staging server (in the database) 100% the same as production?

davy_yg's avatar
Level 27

@Sinnbeck This is the only thing I need to do right?

php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"

I don't know where to type this codes:

	\Debugbar::enable();
	\Debugbar::disable();

There is that bar in my local underneath. If I push it to staging and production will that bar still exists ?

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@davy_yg Yes that is all you need to do. And no, dont use it on production. You check your amount of queries etc. locally. You can always seed some test data so the amount of data is the same on local as it is on production

davy_yg's avatar
Level 27

@Sinnbeck How to disable it on production? If I push it to server through gitlab will it exist on the server?

See, I cannot check with GTMetrix my local server.

I have 1 queries and 13 models in my local.

Sinnbeck's avatar

@davy_yg It will only be enabled if APP_DEBUG=true, and I assume that is false on production.

And I am not telling you to use GTMetrix. I am telling you to do what developers do, and inspect what queries are being made, and how many models you are loading.. Remember to seed your local database so you can get proper data.

davy_yg's avatar
Level 27

@Sinnbeck I have 1 query and 13 models in my local. in my index page.

I think that's a small amount of query and models.

Sinnbeck's avatar

@davy_yg And you have the same amount of records as production? There is huge difference if your local has 13 records and production has 1000

davy_yg's avatar
Level 27

@Sinnbeck

This is the amount of data in production:

10 Lead

34 Quotation

6 Promo Survey

Sinnbeck's avatar

@davy_yg Ok. Bad server perhaps? Did you check the page yourself in the browser?

davy_yg's avatar
Level 27

@Sinnbeck Now it's a B - I retest it without changing anything.

I don't think it's a bad server. This is the best server I could find. In staging it's an A.

So basically through debugger I should reduce the numbers of queries if it is numerous, right?

this is only a landing page not a giant ecommerce site.

Sinnbeck's avatar

@davy_yg Then getting it to A shouldnt be that hard. But it is hard to say exactly what the problem is then. Maybe try running lighthouse directly on the page (F12->Lighthouse) and see if that gives a more precise score.

davy_yg's avatar
Level 27

@Sinnbeck

82 Performance 64 Accessibility 62 Best Practices 60 SEO

First Contentful Paint 1.4 s Time to Interactive 2.4 s Speed Index 2.0 s Total Blocking Time 0 ms Largest Contentful Paint 1.5 s Cumulative Layout Shift 0.16

Is Google Chrome the best browser for developer to code? I usually use Firefox to code since it is more adaptable to other browsers (more likely for be organize for other browsers)

Sinnbeck's avatar

@davy_yg 1.4 seconds is a long time.. I honestly cannot say what on the page is so slow. Did you try the same for the staging site?

I personally use both to make sure my code work. Chrome for the daily work, as I prefer the dev tools.

davy_yg's avatar
Level 27

@Sinnbeck

Eliminate Render Blocking Resources:

		URL 	Transfer Size 	Download Time
		https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css
			20.0KB 	1.1s
		https://code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css
			8.37KB 	1.2s
		https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
			33.4KB 	1.2s
		https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js
			11.7KB 	305ms
		https://www.orderblind.com/js/pawcarousel.jquery.min.js
			2.57KB 	256ms 

It's Medium High

tykus's avatar

All other things being equal, I would be looking at the database and the number of records/models you are working with on production vs. staging.

Please or to participate in this conversation.