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?