Duplicate Page instances being created in the panel

I create a blueprint. I set just the title ‘SomePage’, otherwise it remains empty.

I then create a model also called ‘SomePage’. Besides the constructor containing a logging statement and a call to the parent constructor, I do not add any code at all.

The logging shows that in the panel always two, sometimes three or even four instances of SomePage are created when loading the page. Why is this?

As an additional test I then implemented children() and created blueprint and model called SomeSubPage and added 20 entries. It show that the multiple instances are created in parallel (I do not know how to name it otherwise as I do not know what is going on). This is how it looks in the log:

– SomePage
– SomePage
– SomeSubPage 1
– SomeSubPage 1
– SomeSubPage 2
– SomeSubPage 2

Or with three instances being created:

– SomePage
– SomePage
– SomePage
– SomeSubPage 1
– SomeSubPage 1
– SomeSubPage 1
– SomeSubPage 2
– SomeSubPage 2
– SomeSubPage 2

What exactly is in your models?

Nothing (so the minimum: title and slug). It’s an otherwise empty test project.

Does the number of entries in your log match the number of api requests fetched from the panel?
E.g. a page with 2 sections would fetch 1 request for the page and 2 requests for the sections. For pages sections it makes sense to load the model aswell.

Ok, I understand.

But why are two instances created one for the page and one for the section? It is the same data from the same file(s). This duplicates the amount file access. Just being curious.

The sections are loaded asynchronously in the panel and therefore in a separate http request. Two different requests can’t (and probably should not) share the same instance.

The panel is a Vue app that communicates through a REST api with the backend. It is not a single Kirby instance as when you work with data in a template or so.

Ok. Did not think of that. Makes sense. A lot of sense. Thank you very much!