/** * {@inheritDoc} */ protected function sendHeader($header, $content) { if (!$this->sendHeaders) { return; } if ($this->response) { $this->response->setHeader($header, $content, true); } else { $this->headers[$header] = $content; } }
/** * Helper function to enable the http cache for a single shopware controller. * * @param int $cacheTime * @param array $cacheIds */ public function enableControllerCache($cacheTime = 3600, $cacheIds = array()) { $this->response->setHeader('Cache-Control', 'public, max-age=' . $cacheTime . ', s-maxage=' . $cacheTime, true); $this->registerEsiRenderer(); $this->setCacheIdHeader($cacheIds); }
/** * Adds HTTP headers to specify that the Response needs to be parsed for ESI. * * This method only adds an ESI HTTP header if the Response has some ESI tags. * * @param Response $response A Response instance */ private function addSurrogateControl(Response $response) { $response->setHeader('Surrogate-Control', 'content="ESI/1.0"'); }
/** * */ public function setCacheIdHeader() { $controllerName = $this->request->getModuleName() . '/' . $this->request->getControllerName(); $cacheIds = array(); switch ($controllerName) { case 'widgets/listing': $categoryId = (int)$this->request->getParam('sCategory'); if (empty($categoryId)) { $categoryId = (int)Shopware()->Shop()->get('parentID'); } $cacheIds[] = 'c-' . $categoryId; break; case 'frontend/index': $categoryId = (int)Shopware()->Shop()->get('parentID'); $cacheIds[] = 'c-' . $categoryId; break; case 'frontend/detail': case 'frontend/listing': $categoryId = $this->request->getParam('sCategory', 0); while ($categoryId > 1) { $category = Shopware()->Models()->find( 'Shopware\Models\Category\Category', $categoryId ); if ($category === null) { break; } $cacheIds[] = 'c-' . $category->getId(); $categoryId = $category->getParentId(); } break; } if (!empty($cacheIds)) { $this->response->setHeader('x-shopware-cache-id', implode(', ', $cacheIds)); } }