Best Approach to Reduce TTFB on Kirby 3 Site?

I was wondering whether anyone has any experience with trying to reduce page loading times - specifically, TTFB on a server that is already optimally configured. We have a Kirby 3 site, with NO page caching atm.

Based on your experience, does turning Kirby’s page cache ON make a difference? Is it better to use memcached? What would you recommend?

First things that comes to mind are Caching and a CDN (if you care about speed everywhere on the globe).

I personally use memcached on my sites but I have no idea if Memcached is performing always better than other methods.

2 Likes

I suppose opcache is already activated? That would be the first step before you use Kirby’s cache. Afterwards I can recommend apcu as cache engine. It was really easy to setup and configure and is pretty fast. Memcached is the next step if you need even more.

2 Likes

like it was said before speeding up php execution using opcache and apcu helps a lot.
turing on memcached for the core site cache will also make a huge difference IF you use the core pages cache. if you can not use php caching for some reason or subset of pages consider analysing your code with https://github.com/jokkedk/webgrind and cache parts of your logic. from my experience any calls to kirbys collections/children/filter can be speed up that way. personally i am using my https://github.com/bnomei/kirby3-lapse plugin. but make sure the file cache read time is faster than the skipped logic. (using lapse plugin with memcached is not easily possible yet)

Thank you for the suggestions, guys!

@bastianallgeier @bnomei opcache is indeed on.

@manuelmoreale I’ve done a few experiments, using Kirby’s core page cache by itself, and then configured to use memcached. I haven’t been able to gain any substantial speed improvements - e.g., between 10-20ms only, on a page that loads at about 750ms.

@bnomei @bastianallgeier in your experience, are there situations where using memcached is going to actually make a substantial difference?

When you have a TTFP of 750 ms with caching there’s clearly something going wrong. Either the cache is not working correctly, or something shady is happening in your plugins.

Caching is happening pretty early in the process and it should have significant influence on the response times. Maybe it makes sense to have a closer look at this.

Sorry, @bastianallgeier, I didn’t explain myself properly: the cache IS working perfectly, and the current TTFB is about 75ms. The total page load time is about 750ms - so, we’re super happy with the speed! :smiley:

My doubt now is about memchached: turning it on did not seem to make much difference at all in loading speed. Without memcached, the TTFB is about 85ms, and 75ms with it (hardly worth the trouble). So, I was wondering whether this is ‘normal’, or whether I should look into my memcached config. If this IS normal, then are there specific situations when using memcached WOULD make a substantial difference?..

In my experience (on K2 installations), having huge “file”-caches has negative impact when it gets flushed (e.g. when an editor saves a page in the panel) because the folder listing to delete all its contents takes a while. This degraded the UX in the panel quite a bit, so on some of my sites I decided to not use file-caching for that.

I think using memcached (or other caching tools such as apc, etc) have better performance for this; but they come with a cost (extra money; but also an extra level of complication - I couldn’t easily see what happened in my memcached database, nor debug it - but that could be due to my poor knowledge about them).

I’ve noticed K3 caches work in a different way now; they use subfolders which would probably speed up the file listings quite a bit by default. I haven’t tested this further though.

Is it possible/desirable to use Redis for caching Kirby 3 sites? - and if so, how do we configure it?

I’m glad that I misunderstood you :slight_smile:

To be honest, I haven’t benchmarked the different cache engines so far. I agree with @bvdputte that flushing the cache is probably faster with apcu, memcache and co in comparison to the file cache, but I don’t think that you will see massive differences between apcu and memcache for example.