2

I have a Drupal 8 standard installation on Azure. I wrote a block that uses PHP to load external content; I added a timestamp to the block as well. Under Page cache maximum age, the site is set to no caching. When I refresh the page, the timestamp doesn't update telling me it's not attempting to reload. If I manually clear the cache, all is good and the timestamp updates.

Why would this be?

As I mentioned before, these blocks are loading external content. Ideally I could set it so that these blocks alone wouldn't be cached. Is this possible?

1 Answer 1

0

To disable caching of the block add this to the php code:

  $build['#cache']['max-age'] = 0;
  \Drupal::service('page_cache_kill_switch')->trigger();

This is a similar question Caching of blocks for anonymous user

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.