May 11, 2020 in Drupal 8

Caching in drupal 8 is quite nifty, here's a snippet on how to completely disable caching in your controller.

The following controller will never be cached. Why? Because of the option we added in the bottom. Note that it is also possible to disable the caching in the page controller itself. For more information about caching, read this blogpost: Caching in drupal 8 explained.

api_manager.trigger:
  path: '/admin/api/trigger/{uuid}'
  defaults:
    _title: 'Trigger api call'
    _controller: '\Drupal\api_manager\Controller\externalTrigger::receive'
  requirements:
    _permission: 'access content'
  options:
    no_cache: 'TRUE'