I have a page generated by a custom module that contains two sections:
- Product info
- Recently viewed products
The product info only changes when the product is updated.
Recently viewed products are unique to every visitor (data is stored in
Each section has its own render array.
'productinfo' => [ // ... '#cache' => [ 'tags' => ['product:1234'] ] ], 'recentlyviewed' => [ // ... '#lazy_builder' => array( // .... ), '#create_placeholder' => TRUE, '#cache' => [ 'max-age' => 0 ] ]
The behaviour I expect is that the dynamic page cache can cache the
productinfo section, but the recentlyviewed would never be cached. However, if a session has not yet been started (i.e. first page view), the entire html page is cached to the
cache_render DB table, and
cache_dynamic_page_cache is always empty.
X-Drupal-Dynamic-Cache header is always set to
How can I get the dynamic page cache to cache the product info section?