private function setCacheHeaders(Response $response)
	{
		/** @var PageModel $objPage */
		global $objPage;

		if (($objPage->cache === false || $objPage->cache < 1) && ($objPage->clientCache === false || $objPage->clientCache < 1))
		{
			$response->headers->addCacheControlDirective('no-cache');
			$response->headers->addCacheControlDirective('no-store');

			return $response->setPrivate();
		}

		// Do not cache the response if a user is logged in or the page is protected
		// TODO: Add support for proxies so they can vary on member context
		if (FE_USER_LOGGED_IN === true || BE_USER_LOGGED_IN === true || $objPage->protected || $this->hasAuthenticatedBackendUser())
		{
			$response->headers->addCacheControlDirective('no-cache');
			$response->headers->addCacheControlDirective('no-store');

			return $response->setPrivate();
		}

		if ($objPage->clientCache > 0)
		{
			$response->setMaxAge($objPage->clientCache);
		}

		if ($objPage->cache > 0)
		{
			$response->setSharedMaxAge($objPage->cache);
		}

		// Tag the response
		if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
		{
			/** @var ResponseTagger $responseTagger */
			$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
			$responseTagger->addTags(array('contao.db.tl_page.' . $objPage->id));
		}

		return $response;
	}
private function setCacheHeaders(Response $response)
	{
		/** @var PageModel $objPage */
		global $objPage;

		if (($objPage->cache === false || $objPage->cache < 1) && ($objPage->clientCache === false || $objPage->clientCache < 1))
		{
			$response->headers->addCacheControlDirective('no-cache');
			$response->headers->addCacheControlDirective('no-store');

			return $response->setPrivate();
		}

		// Do not cache the response if a user is logged in or the page is protected
		// TODO: Add support for proxies so they can vary on member context
		if (FE_USER_LOGGED_IN === true || BE_USER_LOGGED_IN === true || $objPage->protected || $this->hasAuthenticatedBackendUser())
		{
			$response->headers->addCacheControlDirective('no-cache');
			$response->headers->addCacheControlDirective('no-store');

			return $response->setPrivate();
		}

		if ($objPage->clientCache > 0)
		{
			$response->setMaxAge($objPage->clientCache);
		}

		if ($objPage->cache > 0)
		{
			$response->setSharedMaxAge($objPage->cache);
		}

		// Tag the response
		if (System::getContainer()->has('fos_http_cache.http.symfony_response_tagger'))
		{
			/** @var ResponseTagger $responseTagger */
			$responseTagger = System::getContainer()->get('fos_http_cache.http.symfony_response_tagger');
			$responseTagger->addTags(array('contao.db.tl_page.' . $objPage->id));
		}

		return $response;
	}
private function setCacheHeaders ( Response $ response ) { /** @var PageModel $objPage */ global $ objPage ; if ( ( $ objPage -> cache === false || $ objPage -> cache < 1 ) && ( $ objPage -> clientCache === false || $ objPage -> clientCache < 1 ) ) { $ response -> headers -> addCacheControlDirective ( 'no-cache' ) ; $ response -> headers -> addCacheControlDirective ( 'no-store' ) ; return $ response -> setPrivate ( ) ; } // Do not cache the response if a user is logged in or the page is protected // TODO: Add support for proxies so they can vary on member context if ( FE_USER_LOGGED_IN === true || BE_USER_LOGGED_IN === true || $ objPage -> protected || $ this -> hasAuthenticatedBackendUser ( ) ) { $ response -> headers -> addCacheControlDirective ( 'no-cache' ) ; $ response -> headers -> addCacheControlDirective ( 'no-store' ) ; return $ response -> setPrivate ( ) ; } if ( $ objPage -> clientCache > 0 ) { $ response -> setMaxAge ( $ objPage -> clientCache ) ; } if ( $ objPage -> cache > 0 ) { $ response -> setSharedMaxAge ( $ objPage -> cache ) ; } // Tag the response if ( System :: getContainer ( ) -> has ( 'fos_http_cache.http.symfony_response_tagger' ) ) { /** @var ResponseTagger $responseTagger */ $ responseTagger = System :: getContainer ( ) -> get ( 'fos_http_cache.http.symfony_response_tagger' ) ; $ responseTagger -> addTags ( array ( 'contao.db.tl_page.' . $ objPage -> id ) ) ; } return $ response ; }
Set the cache headers according to the page settings.

@param Response $response The response object

@return Response The response object
Set the cache headers according to the page settings .