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

kokoshneta's avatar

Windows Server: First request *very* slow, then normal

I’m developing a site which is to be deployed on a Windows Server 2019 (IIS) using an SQL Server database, hosted on a VPS with Plesk.

So far, I’ve primarily been developing from my Macs at home, but connecting directly to the database on the remote server (which already has existing production data to fetch). This of course adds some overhead, so requests aren’t very fast (generally 1.5–2.5s), but I can live with that. Requests though my local .test domain are generally always equally fast.

I recently deployed the site to a testing subdomain on the server to see make sure everything works and see how speeds are when mimicking a production environment on the actual server, without the extra request overhead and all sorts of dev stuff, with routes and configs cached, etc. The test domain is password-protected, but I have the username and password stored in all my browsers, so authentication happens transparently.

Generally, things work well, and full-page response times are around 200–800ms, which is perfectly satisfactory for this type of static site.

However, if I haven’t visited the site for a while (don’t know exactly how long – overnight will do it), then the first request I make to the test site is very slow, usually 10+ seconds. That is obviously not acceptable.

Any subsequent requests are very fast and responsive, even from different browsers or a different device, so I suspect some sort of server-side caching must be involved… but I don’t really know anything about how Windows Server / IIS caching works. Googling the issue, I’ve found similar reports of slow first requests, with people saying that caching is likely the cause – but those were for ASP or .NET apps (which require compiling), so it may not be comparable. They also report first requests being something like 4–6 times slower, whereas mine are more like 15–50 times slower. Plus it just seems quite bizarre to me that loading any reasonably optimised and not-too-complex Laravel app should take a server 10+ seconds under any circumstances.

Does anyone have experience deploying Laravel apps to Windows Server and have any idea what may be causing such extremely long first response times? And how to get it fixed?

0 likes
5 replies
Sinnbeck's avatar

Did some googling as well

https://getridbug.com/asp-net/specific-application-in-iis-taking-is-slow-after-worker-process-stops-after-ideal-timeout-long-time-to-serve/

When using IIS 7.0 and later, by default, the worker process is terminated after a period of inactivity.

It is recommended to start the work process immediately after IIS is started, and set the "Startup Mode" to AlwaysRunning.

Here is the steps:

Find your site in the application pool Click Advanced Settings in the right toolbar Then set startmode to alwaysrunning

1 like
kokoshneta's avatar

@Sinnbeck Aha, the worker process – also a likely culprit!

Start mode was indeed set to onDemand. I’ve set it to alwaysRunning now (not sure if IIS needed a restart or not for the change to take effect, but I gave it one just in case).

I’ll wait a few hours and then test to see if that’s fixed it.

kokoshneta's avatar

@Sinnbeck Unfortunately that doesn’t seem to have made much of a difference. Gave it an hour and visited again, and the first load was still at 5+ seconds. :-(

Sinnbeck's avatar

@kokoshneta Dang :( I found some results for a auto warm plugin, but all the links are dead. I assume it no longer exists. Hope someone has knowledge in regards to IIS. Perhaps consider posting on stackoverflow as well

1 like
kokoshneta's avatar
kokoshneta
OP
Best Answer
Level 27

Seems I forgot to update here (@sinnbeck).

I asked on Serverfault and managed to get it working by changing the following application pool settings:

  • setting Process Model > Idle Timeout time to a very high number (1740)
  • setting Process Model > Idle Timeout Action to Suspend
  • setting Recycling > Regular Time Interval to 0 (zero)

That seems to have done it. First requests are still slower, but in the vicinity of two to three seconds, which I can live with. No longer enough to make the user think the site is not loading.

Please or to participate in this conversation.