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

GTHell's avatar

First Connection is always so slow. Why?

Every time the app is idle and then I make a post or get request for some query then it take 5-6 second but after that connection it will be normal. What causing this? Is the server going into a sleep mode?

0 likes
4 replies
bobbybouwmann's avatar

This can be related to caching on either your server or in your application. The first time your run your application Laravel will try to find all php classes and put the reference of them in one file. After that it will reference that cache file which is much faster than looking up each class all the time.

It can also be related to OPcaching or any other kind of caching. Also the hosting way depends. Do you use shared hosting? Or anything else?

GTHell's avatar

@BOBBYBOUWMANN - I'm running in development mode locally with php artisan serve. The end system is intranet with window servers 12.

My current setup was Docker sql server + php artisan serve.

bobbybouwmann's avatar

@GTHELL - Mmh, that shouldn't give a slow first connection in general. Do you rebuild the container before you start the site?

GTHell's avatar

@BOBBYBOUWMANN - The problem happen with any database connection, whether it's installed sql or the sql server on the server.

Please or to participate in this conversation.