I can't seem to find a straight answer online about whether it is possible to exclude just one component of a page from being cached.
My component appears on all pages of the site and comes from a custom theme function rendered in page.html.twig from the following in mytheme_preprocess_page
:
$alerts_renderable = [
'#theme' => 'my_alerts',
];
$variables['alerts'] = $alerts_renderable;
I've tried adding #cache => ['max-age' => 0]
in that render array to no effect. I read elsewhere that changing max-age has no effect on anonymous visitors. Has anyone had success in ever doing this?
The component is an alert bar that site admins can enter text via a settings page on the backend. That message appears in the alert bar on every page of the site. Currently, when admins change the message, it requires a cache clear for the new message to be publicly visible