I am invalidating a cache tag in KernelEvents::REQUEST
event:
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = ['onRequest', 100];
return $events;
}
public function onRequest(GetResponseEvent $event) {
if ($this->request->cookies->has('myValue')) {
$this->cacheTagsInvalidator->invalidateTags(['my_tag']);
}
}
When I refresh the page the tag is invalidated but the changes are showing on the next refresh, to which event/hook/etc. do I need to subscribe me to see my changes in single refresh ?
Edit 1: I have 'Internal Page Cache' module installed. If I uninstall it, the code above works fine.
Edit 2: Added the if
condition.
onRequest
function executes to late.