logo

Disable cache for specific page routing in custom module in Drupal 8 or 9

25
October

Disable cache for specific page routing in custom module in Drupal 8 or 9
By: Anonymous | Published On: Mon, 10/25/2021 - 19:10

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' 

Need Help ?