/** * Update response headers * * @param Response $response * @param ReadNodeInterface $node * @param Request $request * * @return Response */ protected function updateNodeResponse(Response $response, ReadNodeInterface $node, Request $request) { $tagManager = $this->get('open_orchestra_base.manager.tag'); $cacheableManager = $this->get('open_orchestra_display.manager.cacheable'); $cacheTags = array($tagManager->formatNodeIdTag($node->getNodeId()), $tagManager->formatLanguageTag($node->getLanguage()), $tagManager->formatSiteIdTag($node->getSiteId())); $cacheableManager->addCacheTags($cacheTags); if ($this->has('esi') && $this->get('esi')->hasSurrogateCapability($request)) { $response = $cacheableManager->setResponseCacheParameters($response, $node->getMaxAge(), CacheableInterface::CACHE_PUBLIC, true); } else { $cacheInfo = $this->get('open_orchestra_front.manager.node_response_manager')->getNodeCacheInfo($node); $privacy = $cacheInfo['isPublic'] ? CacheableInterface::CACHE_PUBLIC : CacheableInterface::CACHE_PRIVATE; $response = $cacheableManager->setResponseCacheParameters($response, $cacheInfo['MaxAge'], $privacy); } return $response; }
/** * Browse the hole $node to calculate the general cache policy of the $node * according to the areas and blocks. * If a block is private, the hole $node becomes private * The Max-age of the node is the min of the Max-age of all blocks * * @param ReadNodeInterface $node * * @return array */ public function getNodeCacheInfo(ReadNodeInterface $node) { return $this->getCacheInfoFromAreas($node->getAreas(), $node->getMaxAge()); }