request->getMethod() !== 'GET') { return; } $path = md5($event->request->getPathInfo()); $serialized = apcu_fetch($path); if (! is_string($serialized)) { return; } /** @var Response|null $response */ $response = unserialize($serialized); $event->response = $response; $event->stopped = true; } #[AsListener(RequestEvent::class, 99)] public function doCache(RequestEvent $event): void { if ($event->response === null) { return; } $path = md5($event->request->getPathInfo()); apcu_add($path, serialize($event->response)); } }