Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291456

Cache tags for anonymous user with internal page cache?

$
0
0

Is it possible to change an array value dynamic (with Internal Page Cache) for anonymous users with the usage of cache tags?

The documentation says no: Internal Page Cache

But this documentation (Cache Tags) says: «Comprehensive use of cache tags across Drupal 8 allows Drupal 8 to ship with its Internal Page Cache enabled by default.»

What i want
i want to use the cookie data to create custom classes in a twig template (page.html.twig).

So i have tested this:

<?php
function mymodule_preprocess_page(&$variables) {
  $variables['#cache'] = [
      'contexts' => array('cookies:customCookie'),
      'max-age' => 60,
    ];
}
?>

This works great for authenticated users but not for anonymous users.

My question
Can i use cache tags to make this also works for anonymous users without having to disable the Internal Page Cache module?


Viewing all articles
Browse latest Browse all 291456

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>