Lots of pages, slow start

i have a rather large site with 3k pages in subfolders. i avoid using stuff like $site()->index() and cache queries/filter/collections a lot. still a great deal of time is spent in these two functions (tracked with xdebug-profiler and webgrind).

Content->__construct()
Page->inventory()

any ideas how to avoid these calls even more? maybe if explained when they are called i could avoid them better?

I did a quick search through the core. And both methods are used in conjunction with files/file meta data and the cache. Have a look yourself in your fav editor, searching for inventory and new Content.

Besides optimizing as much as possible, enable the file cache. The first visitor that hits the page upon a cache flush will have the “penalty” of the page load, but every consecutive visitor will be served a cached version.

Disclaimer: this “solution” is not great if there’s a lot of editorial updates of the site (each update flushes the cache).

@bvdputte i have lots dynacmic lists and filtering as well as editorial updates. but i probably should just cache the html output manually for a few seconds to reduce the processing load.

@texnixe i see. thanks. most of my calls seem to originate from $page->children() which trigger the inventory() of various sub-objects. what do you think will happen if i persist the inventory array of pageobjects between two skript calls? the current $page->cache object is only for one skript call, not for a session, or multiple pageviews at the same time, right?

like saving the array to a file and read it back if within a few seconds?

like with this simple json read-write? (just without the encode/decode typo).

creating and loading my cache here…
https://github.com/getkirby/kirby/blob/master/core/page.php#L295

clearing my custom cache of inventory here as well…
https://github.com/getkirby/kirby/blob/master/core/page.php#L70

i know doing file.cache could solve some problems but i also want to speed up the processing of my massive page collections.

Filtering and dynamic lists should get cached too (in my experience). Just make sure each URL always generates the same HTML output.

@bnomei I don’t know, I haven’t had an opportunity to look into this sort of stuff yet. I’d just try if that gives you a performance boost or not.

And then wait for Kirby 3… :shushing_face:

Maybe check out https://github.com/jenstornell/kirby-time-cache ? This might be interesting… You can set your own caches, but then you’ld have to flush them yourself though!

1 Like