I noticed my Craft website is slower to load when it has been idle for awhile. It can take up to 3-4 seconds for the first load, and then it goes down to about 500ms (which is fine) after the first page. I'm also using cache so I could get my query count to about 20-30 per page. I have other websites (non Craft) on the server that are fast to load even when they have been idle for awhile. Any idea what's causing this?
1 Answer
You mention you're using cache, which could mean a whole lot of things, but the symptoms you're describing are typical of what you'd see if you're doing some heavy-handed things inside of a {% cache %}, you let that expire, then you're the first person to hit the page when the cache has to rebuild.
That {% cache %}
tag, by default, will purge its cache every 24 hours unless you've specified otherwise.
-
Thanks. Yes when the cache expired it goes up quite a lot (100 queries to build the 3 level nav menu), but it can happen multiple times within 24h. I should find a way to optimize this nested menu instead.– FraboCommented Jun 2, 2016 at 13:31
-
Maybe you've got other levels of caching going on as well and they're expiring (Varnish, PHP opcache, etc.)– Brad Bell ♦Commented Jun 2, 2016 at 16:30