Example #1
0
 /**
  * Check if request can be cached
  * @param Zend_Controller_Request_Http $request
  * @return bool
  */
 public function allowCache(Zend_Controller_Request_Http $request)
 {
     $res = parent::allowCache($request);
     if ($res) {
         $params = $this->_getSessionParams();
         $queryParams = $request->getQuery();
         $queryParams = array_merge($queryParams, $params);
         $maxDepth = Mage::getStoreConfig(Enterprise_PageCache_Model_Processor::XML_PATH_ALLOWED_DEPTH);
         $res = count($queryParams) <= $maxDepth;
     }
     return $res;
 }
Example #2
0
 /**
  * Prepare response body before caching
  *
  * @param Zend_Controller_Response_Http $response
  * @return string
  */
 public function prepareContent(Zend_Controller_Response_Http $response)
 {
     /** @var Enterprise_PageCache_Model_Processor */
     $processor = Mage::getSingleton('enterprise_pagecache/processor');
     $countLimit = Mage::getStoreConfig(Mage_Reports_Block_Product_Viewed::XML_PATH_RECENTLY_VIEWED_COUNT);
     // save recently viewed product count limit
     $cacheId = $processor->getRecentlyViewedCountCacheId();
     if (!Mage::app()->getCache()->test($cacheId)) {
         Mage::app()->saveCache($countLimit, $cacheId);
     }
     // save current product id
     $product = Mage::registry('current_product');
     if ($product) {
         $cacheId = $processor->getRequestCacheId() . '_current_product_id';
         Mage::app()->saveCache($product->getId(), $cacheId);
         Enterprise_PageCache_Model_Cookie::registerViewedProducts($product->getId(), $countLimit);
     }
     return parent::prepareContent($response);
 }
Example #3
0
 /**
  * Prepare response body before caching
  *
  * @param Zend_Controller_Response_Http $response
  * @return string
  */
 public function prepareContent(Zend_Controller_Response_Http $response)
 {
     $cacheInstance = Enterprise_PageCache_Model_Cache::getCacheInstance();
     /** @var Enterprise_PageCache_Model_Processor */
     $processor = Mage::getSingleton('enterprise_pagecache/processor');
     $countLimit = Mage::getStoreConfig(Mage_Reports_Block_Product_Viewed::XML_PATH_RECENTLY_VIEWED_COUNT);
     // save recently viewed product count limit
     $cacheId = $processor->getRecentlyViewedCountCacheId();
     if (!$cacheInstance->getFrontend()->test($cacheId)) {
         $cacheInstance->save($countLimit, $cacheId, array(Enterprise_PageCache_Model_Processor::CACHE_TAG));
     }
     // save current product id
     $product = Mage::registry('current_product');
     if ($product) {
         $cacheId = $processor->getRequestCacheId() . '_current_product_id';
         $cacheInstance->save($product->getId(), $cacheId, array(Enterprise_PageCache_Model_Processor::CACHE_TAG));
         $processor->setMetadata(self::METADATA_PRODUCT_ID, $product->getId());
         Enterprise_PageCache_Model_Cookie::registerViewedProducts($product->getId(), $countLimit);
     }
     return parent::prepareContent($response);
 }
 /**
  * Return cache page id without application. Depends on GET super global array.
  *
  * @param Enterprise_PageCache_Model_Processor $processor
  * @return string
  */
 public function getPageIdWithoutApp(Enterprise_PageCache_Model_Processor $processor)
 {
     $pageId = parent::getPageIdWithoutApp($processor);
     return $this->_appendCustomerRatesToPageId($pageId);
 }