Magento caching

Тема в разделе "Magento", создана пользователем GoMage, 25 мар 2014.

  1. GoMage

    GoMage

    Регистрация:
    8 янв 2014
    Сообщения:
    13
    Симпатии:
    2
    Sometimes it is necessary to update only a few Magento blocks – a footer and a header. Let us review how to enable the option of periodical update and caching of other Magento blocks.


    General information


    In order to refresh the cache it is sometimes enough to go to the admin panel and update the data. If you have caching disabled, then you need to do the following:

    · Go to the admin panel, then to System > Cache Management;

    · Select all cache types;

    · Select ‘Enable’ in the Actions field;

    · Click ‘Submit’.


    Let us review the details of the information storage. As we discussed before, storing cache is necessary to make the store work faster, this parameter (time interval) is counted in seconds and is updated or generated every hour. You should remember that the old data, even already non-existing pages or erroneous forms, are not deleted but still stored in the system, on the hard drive.


    Eventually, the amount of the old data may become too large and they may take all disk space or hosting server memory, so it is necessary to regularly delete the caching results.


    Tag names


    Special tags are used in programming and system administration in order to find a specific element. In our case they can speed up the process of finding the necessary cache elements, that is why some forum users usually advise to use at least two tags, e.g. ‘website’ and ‘cache’.


    Tags configuration


    <?php

    class Magebase_Example_Block_Cached extends Mage_Core_Block_Abstract

    {

    protected function _construct()

    {

    $this->addData(array(

    'cache_lifetime' => 3600,

    'cache_tags' => array(Mage_Core_Model_Website ::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)

    ));

    }

    ...

    }


    Remember to save the data after any modifications.


    One more of the important Magento cache items is tag identifier. This identifier is unique for each tag and it is not recommended to use it in work.


    In order to automatically generate unique keys in Magento tags you should use the option getCacheKeyInfo ():


    public function getCacheKeyInfo()

    {

    return array(

    'EXAMPLE_BLOCK',

    Mage::app()->getStore()->getId(),

    (int)Mage::app()->getStore()->isCurrentlySecure(),

    Mage::getDesign()->getPackageName(),

    Mage::getDesign()->getTheme('template')

    );

    }


    'EXAMPLE_BLOCK' – unique block identifier, it can be formed in the following way - $this->getNameInLayout()


    How does this work? This component changes the code of the product page that is visible to search engine robots and browsers. This allows them to save separate pages without loading them again which positively affects the loading speed and also saves the disk and hosting memory space.


    The code is taken from magebase.com. If you have any additional questions, we recommend you to contact GoMage specialists by leaving a comment or visiting our forum.