Пример #1
0
 /**
  *
  */
 public function dispatchLoopShutdown()
 {
     if ($this->enabled && session_id()) {
         $this->disable("session in use");
     }
     if ($this->disableReason) {
         $this->getResponse()->setHeader("X-Pimcore-Output-Cache-Disable-Reason", $this->disableReason, true);
     }
     if ($this->enabled && $this->getResponse()->getHttpResponseCode() == 200) {
         try {
             if ($this->lifetime && $this->addExpireHeader) {
                 // add cache control for proxies and http-caches like varnish, ...
                 $this->getResponse()->setHeader("Cache-Control", "public, max-age=" . $this->lifetime, true);
                 // add expire header
                 $this->getResponse()->setHeader("Expires", \Zend_Date::now()->add($this->lifetime)->get(\Zend_Date::RFC_1123), true);
             }
             $cacheItem = array("headers" => $this->getResponse()->getHeaders(), "rawHeaders" => $this->getResponse()->getRawHeaders(), "content" => $this->getResponse()->getBody(), "date" => \Zend_Date::now()->getIso());
             $cacheKey = $this->defaultCacheKey;
             $deviceDetector = Tool\DeviceDetector::getInstance();
             if ($deviceDetector->wasUsed()) {
                 $cacheKey .= "_" . $deviceDetector->getDevice();
             }
             CacheManager::save($cacheItem, $cacheKey, array("output"), $this->lifetime, 1000);
         } catch (\Exception $e) {
             \Logger::error($e);
             return;
         }
     } else {
         // output-cache was disabled, add "output" as cleared tag to ensure that no other "output" tagged elements
         // like the inc and snippet cache get into the cache
         CacheManager::addClearedTag("output_inline");
     }
 }
Пример #2
0
 /**
  * @param null $default
  * @return DeviceDetector
  */
 public function device($default = null)
 {
     return DeviceDetector::getInstance($default);
 }