How to optimize the time to first byte?

I am testing a kirby website against
The time to first byte (TTFB) is not good: 0.65s.
The test runs on the specific language version (/en)
The 301 redirect from the root add a 0.3s more to the TTFB.
(compared to a static html page on the same server: 0.050s)

The website is on a decent hosting solution (Gandi Simple hosting L) with varnish cache.

What could be done to have a better TTFB?

thank you

The time to first byte depends solely on your server, so either upgrade it or move it closer to the user (or test location) :slight_smile:

1 Like

Hello Jimmy and thanks for your answer.

For the test, I chose a browser location in Paris and the server is in Paris too.

Like I said in the previous message:

  • a static page takes 0.05s
  • a kirby page takes: 0.65s

So there might be something to optimize with Kirby

Three very effective ways to optimize are:

  • If possible, place the files on an SSD
  • Activate the Kirby cache with Memcached
  • Upgrade to PHP 7

Your values aren’t normal for Kirby, Kirby can be very fast. :slight_smile:


Ok thanks Lukas

  • the hosting provides no SSD option
  • no memcached (there is Varnish by default and APC option)
  • I am going to upgrade to php 7

Strangely, when I activate APC or file cache in Kirby, the TTFB I can read in chrome is worse than before (up to 2s on first load and still 0.7s on refresh). Do you know why?

Then you have a strange hosting provider. Getting static HTML from a memory cache should absolutely be faster than rendering dynamically.

I would probably also look around for a better hosting provider if I were you :blush:

If you plan on building more websites for people and get a little more advanced about this stuff, I’d suggest you to take a look at or (linode have just doubled the RAM on their offerings), I don’t know about Linode, but DigitalOcean have some pretty great toturials about getting up and going which should work for Linode too and they have pre-build images for LAMP and LEMP setups (although you can actually leave out MySQL entirely when running Kirby).

I really hope it helps and that you can bring down that TTFB as performance is often an underestimated feature :ok_hand:

1 Like

thank you all for your answers.

One more question:

  • from php 5.6 APC cache is replaced by OpCache. Is there a way to take advantage of this with Kirby?

@JimmyRittenborg Thanks for the hosting suggestions. I will check that out.

If you have any other hosting recommandations, let me know. (Also, It would be good if there was an option for hosting from France.)

I’ll continue my investigations and let you know.

Hello @francoisromain,

In france, I’ve had a good experience with
Best thing about it is you can start for free. And this is not your typical free hosting, it’s actually quite good although you’ll end up running out of bandwith soon enough :wink: