Gc\Mvc\Service\CacheService::shouldCache PHP Method

shouldCache() protected method

Define if the page should be cached
protected shouldCache ( MvcEvent $event ) : boolean
$event Zend\Mvc\MvcEvent Event
return boolean
    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;
    }