Example #1
0
 protected function getRequiredBlocks($page)
 {
     $fpcConfig = new Amasty_Fpc_Model_Config();
     $config = $fpcConfig->getConfig();
     $blocks = $this->getPageBlocks($page, array_keys($config['blocks']));
     return $blocks;
 }
Example #2
0
 public function saveBlockCache($name, $content, $tags)
 {
     if (in_array($name, array('global_messages', 'messages'))) {
         return;
     }
     if ($name == Amasty_Fpc_Model_Config::getCookieNoticeBlockName()) {
         if (!trim($content)) {
             return;
         }
     }
     if (FALSE !== stripos($this->_backendType, 'database') && $this->getMaxStorageSize() > 0) {
         if ($this->getStorageSize() >= $this->getMaxStorageSize()) {
             return;
         }
     }
     if (!$tags) {
         $tags = array();
     }
     $id = Mage::getSingleton('amfpc/fpc_front')->getBlockCacheId($name);
     $blockTag = Mage::getSingleton('amfpc/fpc_front')->getBlockCacheTag($name);
     $tags[] = Mage_Core_Block_Abstract::CACHE_GROUP;
     $tags[] = $blockTag;
     $lifetime = +Mage::getStoreConfig('amfpc/general/block_lifetime');
     $lifetime *= 3600;
     $content = $this->removeSid($content);
     if ($formKey = Mage::getSingleton('core/session')->getFormKey()) {
         $content = str_replace($formKey, 'AMFPC_FORM_KEY', $content);
     }
     if (Mage::helper('amfpc')->isBlockCompressionEnabled()) {
         $content = gzcompress($content, +Mage::getStoreConfig('amfpc/compression/level'));
         $content = base64_encode($content);
         $content = self::COMPRESSION_PREFIX . $content;
     }
     if (self::STATS_MODE) {
         Mage::getModel('amfpc/stats')->load($id, 'cache_id')->addData(array('cache_id' => $id, 'url' => $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'size' => strlen($content), 'type' => 'block', 'block_name' => $name, 'customer_group' => Mage::getSingleton('amfpc/fpc_front')->getCustomerGroupId(), 'session' => isset($_COOKIE['frontend']) ? $_COOKIE['frontend'] : ''))->save();
     }
     $this->save($content, $id, $tags, $lifetime);
 }