New answers tagged

0

Since you're creating a reference to a location node, you'll know its node id upon saving the event. At that point, you need to call \Drupal\Core\Cache\Cache::invalidateTags([$nid]) where $nid is the node id of the location. There are many possibilities where this could be invoked, for example, in hook_entity_presave()


0

To prevent caching of a particular block: add the below code in theme_name.theme file function theme_name_preprocess_block(&$variables) { if ($variables['plugin_id'] == 'block_id') { $variables['#cache']['max-age'] = 0; } }


1

You need a cache context and a cache tag of the user: $variables['username'] = [ '#markup' => \Drupal::currentUser()->getUsername(), '#cache' => [ 'contexts' => [ 'user', ], 'tags' => [ 'user:' . \Drupal::currentUser()->id(), ], ], ]; You can add this directly in a preprocess hook, but then the rendered ...


0

In drupal 8 you might have to add core/drupal as a dependency of your module. your-custom-module: version: 1.x js: js/your_custom_module.js: {} dependencies: - core/drupal - core/drupalSettings


1

Here's some code that I use to clear Acquia varish via the Purge / Acquia purge modules when a pdf with the same name is uploaded. You could expand on this to clear the styles cache as well. /** * Implements hook_entity_update(). */ function my_module_entity_update(EntityInterface $entity) { $type = $entity->getEntityTypeId(); if ($type != 'file') ...


0

I changed the "Browser and proxy cache maximum age" setting in Configuration > Development > Performance and it appeared to do the trick. It was previously set to "no caching".


1

Is this causing a bug for you, or are you just trying to understand how it works at all? Making the token system integrate with the cache system happened very late in the Drupal 8 development cycle (see https://www.drupal.org/node/2528662). Note that if that optional Token::replace(…, …, …, BubbleableMetadata $bubbleable_metadata = NULL) argument is not ...


Top 50 recent answers are included