Please help with choosing the right cache plugin while serving Cached pages with dynamic elements inside. Here is the simple case of this header:
-
Mini-Cart Bricks element (with dynamic counter and off-canvas with cart total and products )
-
a Favourites with its counter (it doesn’t uses cookies, but storage)
Those two elements have a conditional visibility, so if cart “is empty”, or favorites as shown below:
resulting in this:

No need to say that counters should be delivered dynamically as well, and the mini-cart off-canvas, which is not ajaxfied.
A quick answer will be to serve “non-cached” pages if visitor is-login, or has-cookies. However, the shopping process can be completed without creating an account nor accepting cookies. Favorites use “storage” instead cookies…
Solutions on my mind:
OPTION 1 Serving dynamic Bricks elements as AJAX. There is way to do it?
OPTION 2 Automattic “WP Super cache” plugin allows to serve non-cached elements inside a cache page, with function “cacheaction”. Example:
Create this snippet:
function dynamic_time() {
echo "<div id='current-time'>Current time: " . date('H:i:s') . "</div>";
}
add_cacheaction( 'wpsc_cachedata', 'dynamic_time' );
Then in the template:
<?php if (function_exists('dynamic_time')) dynamic_time(); ?>
This will serve dynamic data on a “WP super cache” cached page.
But, how can I embed the Bricks "Mini Cart” element and other dynamic Bricks elements inside a function?
Or maybe I’m missing something? Any clue is highly appreciated.