Пример #1
0
 /**
  * Modify and cache application response
  *
  * @param \Magento\Framework\App\Response\Http $response
  * @return void
  */
 public function process(\Magento\Framework\App\Response\Http $response)
 {
     if (preg_match('/public.*s-maxage=(\\d+)/', $response->getHeader('Cache-Control')['value'], $matches)) {
         $maxAge = $matches[1];
         $response->setNoCacheHeaders();
         if ($response->getHttpResponseCode() == 200 && ($this->request->isGet() || $this->request->isHead())) {
             $tagsHeader = $response->getHeader('X-Magento-Tags');
             $tags = $tagsHeader ? explode(',', $tagsHeader['value']) : array();
             $response->clearHeader('Set-Cookie');
             $response->clearHeader('X-Magento-Tags');
             if (!headers_sent()) {
                 header_remove('Set-Cookie');
             }
             $this->cache->save(serialize($response), $this->identifier->getValue(), $tags, $maxAge);
         }
     }
 }