Hi,
I'm not using the Page (CMS) bundle, but I want to use the Block bundle, and I want Block's to be cached.
In my template, I've got a block for the header (amongst others):
{{
sonata_block_render({ 'type': 'myproject_website.block.header' }, {
'site_id': 1
})
}}
This works well: the header is displayed correctly.
Now I want to cache the result, as the block involves many database queries. Everything is configured correctly, but every cache is a miss. The reason: the calculated cache key is different each time. I tracked down that the problem has to do with the ID of the Block (Block::$id).
The template gets parsed, and for each block Sonata\BlockBundle\Block\Loader\ServiceLoader::load is executed to create the Block object. This function uses uniqid() for the Block::$id, hence it is different on each request so for the same template block, each requests ends up with a different Block::$id hance a different cache key.
What am I doing wrong here?
Thank you,
Willem van Duijn