How to disable caching on a route with controller in drupal 8 and drupal 9

To disable cache at route level or custom page level, we have multiple ways. Check the following snippet to understand them.

- use 'no_cache' from the routing.yml file OR
- use 'max-age' from the controller method OR
- use 'page_cache_kill_switch' drupal service

Use anyone of the method above to disable cache at routing level or controller level in drupal 8 or drupal 9
copy-icon
copy-icon

Comments

Authors

Read Next