2

My Drupal 8 website consists of multiple custom blocks created from the drupal backend user interface.

As I went from dev to production settings and activating Internal Dynamic Page Cache (set to 1 minute), the custom block content doesn't change on the actual site after editing (for both anonymous and authenticated users). If I go back to editing mode, the changes are persisted as expected.

The changes are visible when I clear the caches (i.e. drush cache-rebuild). I don't have any issues with my own blocks that implements the Block plugin and has a max-age set. Nodes works works as expected too.

What could be wrong?

2

1 Answer 1

0

hope this works ...

<?php
abstract class BlockBase extends PluginBase implements BlockPluginInterface {
  /**
   * Returns generic default configuration for block plugins.
   *
   * @return array
   *   An associative array with the default configuration.
   */
  protected function baseConfigurationDefaults() {
    return array(
      'label' => '',
      'module' => $this->pluginDefinition['module'],
      'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
      'cache' => array(
        'max_age' => 0,
      ),
    );
  }
}

refer to this link block cache api is removed

The following block cache constants have been replaced with the combination of the cache.max_age and ::getCacheContexts() return values (or bubbled cache contexts) on blocks:

DRUPAL_NO_CACHE (equivalent: cache.max_age = 0)
DRUPAL_CACHE_CUSTOM (equivalent: cache.max_age = 0 + Cache::keyFromQuery())
DRUPAL_CACHE_PER_ROLE (equivalent: cache.max_age >0 + user.roles)
DRUPAL_CACHE_PER_USER (equivalent: cache.max_age >0 + user)
DRUPAL_CACHE_PER_PAGE (equivalent: cache.max_age >0 + url)
DRUPAL_CACHE_GLOBAL (equivalent: cache.max_age >0, no cache contexts)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.