protected function shouldCache(MvcEvent $event)
{
$routeMatch = $event->getRouteMatch();
if ($routeMatch === null) {
return false;
}
$routeName = $event->getRouteMatch()->getMatchedRouteName();
$response = $event->getResponse();
$request = $event->getRequest();
if ($routeName != 'cms' or $request->getMethod() != 'GET' or $response->getStatusCode() != 200) {
return false;
}
$application = $event->getApplication();
$serviceManager = $application->getServiceManager();
if ($serviceManager->has('CurrentDocument')) {
$currentDocument = $serviceManager->get('CurrentDocument');
if (!$currentDocument instanceof DocumentModel or $currentDocument->canBeCached() === false) {
return false;
}
}
return true;
}