Answers.Body: <p>I found the event after a more thorough search. Every controller has the <code>EVENT_AFTER_ACTION</code> event, which is triggered after each action. The triggering action can be found with the <code>id</code> attribute on the event.</p>
  <pre><code>Event::on(
    UtilitiesController::class, 
    Controller::EVENT_AFTER_ACTION, 
    function (ActionEvent $event) {
      if ($event-&gt;action-&gt;id == 'clear-caches-perform-action') {
        //do your stuff
      }
    }
  );
  </code></pre>
  <p>I didn't find a way to only listen to the clearing of the data cache. Feel free to add to my answer if you should know.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-07-03T13:42:13.877Z
Answers.LastActivityDate: 2024-07-03T13:42:13.877Z
Answers.UserDisplayName: meredith
Body: <p>I couldn't find a event that is triggered after clearing the cache. Is there one that I didn't see or is there another way to execute a controller action after the cache is cleared? It only concerns the data cache.</p>
  <p>Thanks in advance!</p>
  
Tags: <cache><craft4><events>
Title: Event after Cache Clear
ThreadText: # Event after Cache Clear
  
  (Asked by: username_0 on 2024-07-03)
  
  I couldn't find a event that is triggered after clearing the cache. Is there one that I didn't see or is there another way to execute a controller action after the cache is cleared? It only concerns the data cache.
  
  Thanks in advance!
  
  **Tags:** cache, craft4, events
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-07-03. Score: 1 | Accepted answer
  
  I found the event after a more thorough search. Every controller has the `EVENT_AFTER_ACTION` event, which is triggered after each action. The triggering action can be found with the `id` attribute on the event.
  
  ```
  Event::on(
    UtilitiesController::class, 
    Controller::EVENT_AFTER_ACTION, 
    function (ActionEvent $event) {
      if ($event->action->id == 'clear-caches-perform-action') {
        //do your stuff
      }
    }
  );
  
  ```
  
  I didn't find a way to only listen to the clearing of the data cache. Feel free to add to my answer if you should know.
  
  
  ---
  
  