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).