当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::setClientTtl方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Response::setClientTtl方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::setClientTtl方法的具体用法?PHP Response::setClientTtl怎么用?PHP Response::setClientTtl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Response的用法示例。


在下文中一共展示了Response::setClientTtl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction

 public function indexAction()
 {
     $response = new Response($this->dumper->dump(), 200, array('Content-Type' => 'application/xml'));
     $response->setPublic();
     $response->setClientTtl($this->httpCache['ttl']);
     return $response;
 }
开发者ID:silvestra,项目名称:silvestra,代码行数:7,代码来源:SitemapController.php

示例2: onKernelRequest

 /**
  * Return the response to the context hash request with a header containing
  * the generated hash.
  *
  * If the ttl is bigger than 0, cache headers will be set for this response.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() != HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     if (!$this->requestMatcher->matches($event->getRequest())) {
         return;
     }
     $hash = $this->hashGenerator->generateHash();
     // status needs to be 200 as otherwise varnish will not cache the response.
     $response = new Response('', 200, array($this->hashHeader => $hash, 'Content-Type' => 'application/vnd.fos.user-context-hash'));
     if ($this->ttl > 0) {
         $response->setClientTtl($this->ttl);
         $response->setVary($this->userIdentifierHeaders);
         $response->setPublic();
     } else {
         $response->setClientTtl(0);
         $response->headers->addCacheControlDirective('no-cache');
     }
     $event->setResponse($response);
 }
开发者ID:benr77,项目名称:FOSHttpCacheBundle,代码行数:29,代码来源:UserContextSubscriber.php

示例3: testSetClientTtl

 public function testSetClientTtl()
 {
     $response = new Response();
     $response->setClientTtl(10);
     $this->assertEquals($response->getMaxAge(), $response->getAge() + 10);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:6,代码来源:ResponseTest.php

示例4: rssAction

 public function rssAction($uri = null)
 {
     if (null === $this->application) {
         throw new FrontControllerException('A valid BackBee application is required.', FrontControllerException::INTERNAL_ERROR);
     }
     if (false === $this->application->getContainer()->has('site')) {
         throw new FrontControllerException('A BackBee\\Site instance is required.', FrontControllerException::INTERNAL_ERROR);
     }
     $site = $this->application->getContainer()->get('site');
     if (false !== ($ext = strrpos($uri, '.'))) {
         $uri = substr($uri, 0, $ext);
     }
     if ('_root_' == $uri) {
         $page = $this->application->getEntityManager()->getRepository('BackBee\\NestedNode\\Page')->getRoot($site);
     } else {
         $page = $this->application->getEntityManager()->getRepository('BackBee\\NestedNode\\Page')->findOneBy(array('_site' => $site, '_url' => '/' . $uri, '_state' => Page::getUndeletedStates()));
     }
     try {
         $this->application->info(sprintf('Handling URL request `rss%s`.', $uri));
         $response = new Response($this->application->getRenderer()->render($page, 'rss', null, 'rss.phtml', false));
         $response->headers->set('Content-Type', 'text/xml');
         $response->setClientTtl(15);
         $response->setTtl(15);
         $this->send($response);
     } catch (\Exception $e) {
         $this->defaultAction('/rss/' . $uri);
     }
 }
开发者ID:gobjila,项目名称:BackBee,代码行数:28,代码来源:FrontController.php


注:本文中的Symfony\Component\HttpFoundation\Response::setClientTtl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。