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


PHP Http::setNoCacheHeaders方法代码示例

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


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

示例1: dispatch

 /**
  * Perform action and generate response
  *
  * @param RequestInterface $request
  * @return ResponseInterface|\Magento\Framework\Controller\ResultInterface
  * @throws \LogicException
  */
 public function dispatch(RequestInterface $request)
 {
     \Magento\Framework\Profiler::start('routers_match');
     $routingCycleCounter = 0;
     $result = null;
     while (!$request->isDispatched() && $routingCycleCounter++ < 100) {
         /** @var \Magento\Framework\App\RouterInterface $router */
         foreach ($this->_routerList as $router) {
             try {
                 $actionInstance = $router->match($request);
                 if ($actionInstance) {
                     $request->setDispatched(true);
                     $this->response->setNoCacheHeaders();
                     if ($actionInstance instanceof \Magento\Framework\App\Action\AbstractAction) {
                         $result = $actionInstance->dispatch($request);
                     } else {
                         $result = $actionInstance->execute();
                     }
                     break;
                 }
             } catch (\Magento\Framework\Exception\NotFoundException $e) {
                 $request->initForward();
                 $request->setActionName('noroute');
                 $request->setDispatched(false);
                 break;
             }
         }
     }
     \Magento\Framework\Profiler::stop('routers_match');
     if ($routingCycleCounter > 100) {
         throw new \LogicException('Front controller reached 100 router match iterations');
     }
     return $result;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:41,代码来源:FrontController.php

示例2: setNoCacheHeaders

 /**
  * {@inheritdoc}
  */
 public function setNoCacheHeaders()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setNoCacheHeaders');
     if (!$pluginInfo) {
         return parent::setNoCacheHeaders();
     } else {
         return $this->___callPlugins('setNoCacheHeaders', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php

示例3: testSetNoCacheHeaders

 /**
  * Test setting public cache headers
  */
 public function testSetNoCacheHeaders()
 {
     $timestamp = 1000000;
     $pragma = 'no-cache';
     $cacheControl = 'max-age=0, must-revalidate, no-cache, no-store';
     $expiresResult = 'Thu, 01 Jan 1970 00:00:00 GMT';
     $this->dateTimeMock->expects($this->once())->method('strToTime')->with('-1 year')->willReturn($timestamp);
     $this->dateTimeMock->expects($this->once())->method('gmDate')->with(Http::EXPIRATION_TIMESTAMP_FORMAT, $timestamp)->willReturn($expiresResult);
     $this->model->setNoCacheHeaders();
     $this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue());
     $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue());
     $this->assertEquals($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
 }
开发者ID:nja78,项目名称:magento2,代码行数:16,代码来源:HttpTest.php


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