Disable cache for specific page routing in custom module in Drupal 8 or 9
Example is mentioned below where I have created a path (/mycustompath) so I want disable cache for this page then I have add following syntax with my code in the file (mymodule.routing.yml) or in your routing yml file
options:
no_cache: 'TRUE'
Complete example as below
mymodule.form:
path: '/mycustompath'
defaults:
_title: ''
_form: '\Drupal\workassign\Form\MyTestForm'
requirements:
_permission: 'mymodule custom'
options:
no_cache: 'TRUE'