How to work/flow Enterprise_PageCache_Model_Observer class in Magento? (Magento ver. 1.13.0.2)

Object: $this => Enterprise_PageCache_Model_Observer
Following constants is used in above class :

  • const XML_PATH_DESIGN_EXCEPTION = ‘design/package/ua_regexp’

Following variables is used in above class :

  • $_visitedUrls
  • $_processor
  • $_config
  • $_isEnabled

Some important functions and its purpose in this class:

  • cacheResponse(): This function saves page body into cache storage.
  • processPreDispatch(): Check when cache should be disabled
  • processEntityAction(): It is used for process entity action.
  • cleanCache(): This function is used to clean full page cache.
  • cleanCacheByTags(): This function is used to clean full page cache by tags.
  • cleanExpiredCache(): This function is used to clean expired cache or entity present in full page cache.
  • clearRequestCacheByTag(): This function is used to clear request path cache by tag.

Functions in class Enterprise_PageCache_Model_Observer

  •  
    /** Class constructor
         **/
        public function __construct(array $args = array()) {}
  • /** Check if full page cache is enabled
         * @return bool
         */
        public function isCacheEnabled()
        {
            return $this->_isEnabled;
        }
  • /**Save page body to cache storage
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function cacheResponse(Varien_Event_Observer $observer)   {}
  • /**Check when cache should be disabled
    * @param Varien_Event_Observer $observer
    * @return Enterprise_PageCache_Model_Observer **/
    public function processPreDispatch(Varien_Event_Observer $observer) {}
  • /** Checks whether exists design exception value in cache.
         * If not, gets it from config and puts into cache
         * @return Enterprise_PageCache_Model_Observer **/
         protected function _saveDesignException(){}
  • /**
         * model_load_after event processor. Collect tags of all loaded entities
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer
         */
        public function registerModelTag(Varien_Event_Observer $observer){}
  • /** Retrieve block tags and add it to processor
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer  **/
        public function registerBlockTags(Varien_Event_Observer $observer)  {}
  • /*** Check category state on post dispatch to allow category page be cached
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function checkCategoryState(Varien_Event_Observer $observer){}
  • /**Check product state on post dispatch to allow product page be cached
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer */
         public function checkProductState(Varien_Event_Observer $observer){}
  • /** Check if data changes duering object save affect cached pages
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
         public function validateDataChanges(Varien_Event_Observer $observer){}
  • /** Check if data delete affect cached pages
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer  **/
       public function validateDataDelete(Varien_Event_Observer $observer){}
  • /**Process entity action
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function processEntityAction(Varien_Event_Observer $observer){}
  • /**Clean full page cache
         * @return Enterprise_PageCache_Model_Observer  **/
        public function cleanCache(){}
  • /** Cleans cache by tags
         * @param Varien_Event_Observer $observer
         * @return Mage_Core_Model_Observer **/
        public function cleanCacheByTags(Varien_Event_Observer $observer){}
  • /**Clean expired entities in full page cache
         * @return Enterprise_PageCache_Model_Observer **/
        public function cleanExpiredCache()
        {
      Enterprise_PageCache_Model_Cache::getCacheInstance()->getFrontend()->clean(Zend_Cache::CLEANING_MODE_OLD);
            return $this;
        }
  • /** Invalidate full page cache
         * @return Enterprise_PageCache_Model_Observer **/
        public function invalidateCache()
        {
            Mage::app()->getCacheInstance()->invalidateType('full_page');
            return $this;
        }
  • /**Render placeholder tags around the block if needed
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function renderBlockPlaceholder(Varien_Event_Observer $observer){}
  • /**Check cache settings for specific block type and associate block to container if needed
         * @param Varien_Event_Observer $observer
         * @deprecated after 1.8
         * @return Enterprise_PageCache_Model_Observer **/
         public function blockCreateAfter(Varien_Event_Observer $observer){}
  • /**Set cart hash in cookie on quote change
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
         public function registerQuoteChange(Varien_Event_Observer $observer) {}
  • /** Set compare list in cookie on list change. Also modify recently compared cookie.
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer
         */
        public function registerCompareListChange(Varien_Event_Observer $observer){}
  • /** Set new message cookie on adding messsage to session.
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
         public function processNewMessage(Varien_Event_Observer $observer) {}
  • /** Update customer viewed products index and renew customer viewed product ids cookie
         * @return Enterprise_PageCache_Model_Observer **/
        public function updateCustomerProductIndex(){}
  • /**Set cookie for logged in customer
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function customerLogin(Varien_Event_Observer $observer){}
  • /**Remove customer cookie
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function customerLogout(Varien_Event_Observer $observer){}
  • /** Set wishlist hash in cookie on wishlist change
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
         public function registerWishlistChange(Varien_Event_Observer $observer){}
  • /** Register add wishlist item from cart in admin
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function registerAdminWishlistChange(Varien_Event_Observer $observer){}
  • /** Clear wishlist list
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer  **/
       public function registerWishlistListChange(Varien_Event_Observer $observer){}
  • /** Set poll hash in cookie on poll vote
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function registerPollChange(Varien_Event_Observer $observer) {}
  • /**Clean order sidebar cache
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
         public function registerNewOrder(Varien_Event_Observer $observer){}
  • /**Remove new message cookie on clearing session messages.
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer */
         public function processMessageClearing(Varien_Event_Observer $observer){}
  • /**Resave exception rules to cache storage
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer  **/
        public function registerDesignExceptionsChange(Varien_Event_Observer $observer) {}
  • /** Retrieve cookie instance 
         * @return Enterprise_PageCache_Model_Cookie **/
        protected function _getCookie()
        {
            return Mage::getSingleton('enterprise_pagecache/cookie');
        }
  • /**Check if last viewed product id should be processed after cached product view
         * @deprecated after 1.8 - added dynamic block generation **/
         protected function _checkViewedProducts(){}
  • /** Update info about product on product page
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function updateProductInfo(Varien_Event_Observer $observer) {}
  • /**Check cross-domain session messages
         * @param Varien_Event_Observer $observer
         * @return Enterprise_PageCache_Model_Observer **/
        public function checkMessages(Varien_Event_Observer $observer){}
  • /**Observer on changed Customer SegmentIds
         * @param Varien_Event_Observer $observer
         * @return void **/
        public function changedCustomerSegmentIds(Varien_Event_Observer $observer){}
  • /** Drop top navigation block from cache if category becomes visible/invisible
         * @param Varien_Event_Observer $observer **/
        public function registerCategorySave(Varien_Event_Observer $observer){}
  • /**Register form key in session from cookie value
         * @param Varien_Event_Observer $observer  **/
        public function registerCachedFormKey(Varien_Event_Observer $observer){}
  • /**Clean cached tags for product if tags for product are saved
         * @param Varien_Event_Observer $observer **/
         public function cleanCachedProductTagsForTags(Varien_Event_Observer $observer){}
  • /**Clear request path cache by tag
         * (used for redirects invalidation)
         * @param Varien_Event_Observer $observer
         * @return $this     **/
         public function clearRequestCacheByTag(Varien_Event_Observer $observer){}

Variation of sample data for different pages (Homepage, Product Listing Page, Product Info Page)

Variables:These values for Homepage
URL :
http://localhost/oscp-store/magento_enterprise/index.php

  • $_processor ={Enterprise_PageCache_Model_Processor}[7]
      $_requestId => localhost/oscp-store/magento_enterprise/index.php
      $_requestCacheId => REQEST_3fd38ed276141d9dc9bfa57542eb8056
      $_requestTags =>Array [1]
                      [0] = FPC
      $_metaData => Array [7]
         cache_subprocessor=> Enterprise_PageCache_Model_Processor_Default
         response_header = Array [2]
         routing_aliases= array [1]
                         rewrite_path_requist=
         routing_requested_route = cms
         routing_requested_controller = index
         routing_requested_action = index
         sid_cookie_name = frontend
    
      $_designExceptionExistsInCache => 1403703897
      $_requestProcessor => Enterprise_PageCache_Model_Processor_Default
      $_subprocessor => Enterprise_PageCache_Model_Processor_Default
  • $_config ={Class : class Enterprise_PageCache_Model_Config}[10]
  • $_placeholders =>array[19]

    • reports/product_viewed = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Viewedproducts
      code = VIEWED_PRODUCTS
      cache_lifetime = 86400
      name = ""
    • reports/product_widget_viewed = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Viewedproducts
      code = VIEWED_PRODUCTS
      cache_lifetime = 86400
      name = ""
    • page/html_topmenu = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Catalognavigation
      code = TOPMENU
      cache_lifetime = 86400
      name = "catalog.topnav"
    • checkout/cart_sidebar = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Sidebar_Cart
      code = CART_SIDEBAR
      cache_lifetime = 86400
      name = "
    • catalog/product_compare_sidebar = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Sidebar_Comparelist
      code = COMPARELIST_SIDEBAR
      cache_lifetime = 86400
      name = "
    • core/messages = array[2]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Messages
      code = MESSAGES
      cache_lifetime = 86400
      name = "messages"
      
      [1] = array[4]
      container = Enterprise_PageCache_Model_Container_Messages
      code = GLOBAL_MESSAGES
      cache_lifetime = 86400
      name = "global_messages"
    • reports/product_compared = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Sidebar_Recentlycompared
      code = RECENTLYCOMPARED_SIDEBAR
      cache_lifetime = 86400
      name = ""
    • page/html_welcome = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Welcome
      code = WELCOME
      cache_lifetime = 86400
      name = ""
    • page/template_links = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Accountlinks
      code = ACCLINKS
      cache_lifetime = 86400
      name = "account.links"
    • enterprise_wishlist/customer_sidebar = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Wishlist
      code = WISHLIST
      cache_lifetime = 86400
      name = ""
    • sales/reorder_sidebar = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Orders
      code = ORDERS
      cache_lifetime = 86400
      name = ""
    • enterprise_wishlist/links = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Wishlistlinks
      code = WISHLISTLINKS
      cache_lifetime = 86400
      name = ""
    • poll/activePoll = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Sidebar_Poll
      code = POLL
      cache_lifetime = 86400
      name = ""
    • enterprise_banner/widget_banner = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Banner
      code = WIDGET_ENTERPRISE_BANNER
      cache_lifetime = 86400
      name = ""
    • enterprise_targetrule/catalog_product_item = array[2]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_CatalogProductItem
      code = CATALOG_PRODUCT_ITEM_RELATED
      cache_lifetime = 86400
      name = "catalog.product.related.item"
      
      [1] = array[4]
      container = Enterprise_PageCache_Model_Container_CatalogProductItem
      code = CATALOG_PRODUCT_ITEM_UPSELL
      cache_lifetime = 86400
      name = "catalog.product.upsell.item"
    • enterprise_giftcard/catalog_product_view_type_giftcard_form = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Giftcard
      code = GIFTCARD
      cache_lifetime = 86400
      name = "product.info.giftcard.form"
    •  catalog/product_list_related = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_CatalogProductList
      code = CATALOG_PRODUCT_LIST_RELATED
      cache_lifetime = 86400
      name = "catalog.product.related"
    • catalog/product_list_upsell = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_CatalogProductList
      code = CATALOG_PRODUCT_LIST_UPSELL
      cache_lifetime = 86400
      name = "product.info.upsell"
    • enterprise_wishlist/behaviour = array[1]
      [0] = array[4]
      container = Enterprise_PageCache_Model_Container_Wishlists
      code = WISHLISTS
      cache_lifetime = 86400
      name = ""
    • $_xml = {Mage_Core_Model_Config_Element}[1]

      $placeholders = {Mage_Core_Model_Config_Element}[21]

      • last_viewed_products={Mage_Core_Model_Config_Element}[4]
        block = reports/product_viewed
        placeholder = VIEWED_PRODUCTS
        container = Enterprise_PageCache_Model_Container_Viewedproducts
        cache_lifetime = 86400
      • last_viewed_products_widget = {Mage_Core_Model_Config_Element}[4]
        block = reports/product_widget_viewed
        placeholder = VIEWED_PRODUCTS_WIDGET
        container = Enterprise_PageCache_Model_Container_Viewedproducts
        cache_lifetime = 86400
      • catalog_navigation = {Mage_Core_Model_Config_Element}[5]
        block = page/html_topmenu
        name = catalog.topnav
        placeholder = TOPMENU
        container = Enterprise_PageCache_Model_Container_Catalognavigation
        cache_lifetime = 86400
      • cart_sidebar = {Mage_Core_Model_Config_Element}[4]
        block = checkout/cart_sidebar
        placeholder = CART_SIDEBAR
        container = Enterprise_PageCache_Model_Container_Sidebar_Cart
        cache_lifetime = 86400
      • compare_list_sidebar = {Mage_Core_Model_Config_Element}[4]
        block = catalog/product_compare_sidebar
        placeholder = COMPARELIST_SIDEBAR
        container = Enterprise_PageCache_Model_Container_Sidebar_Comparelist
        cache_lifetime = 86400
      • messages = {Mage_Core_Model_Config_Element}[5]
        block = core/messages
        name = messages
        placeholder = MESSAGES
        container = Enterprise_PageCache_Model_Container_Messages
        cache_lifetime = 86400
      • global_messages = {Mage_Core_Model_Config_Element}[5]
        block = core/messages
        name = global_messages
        placeholder = GLOBAL_MESSAGES
        container = Enterprise_PageCache_Model_Container_Messages
        cache_lifetime = 86400
      • recently_compared_sidebar = {Mage_Core_Model_Config_Element}[4]
        block = reports/product_compared
        placeholder = RECENTLYCOMPARED_SIDEBAR
        container = Enterprise_PageCache_Model_Container_Sidebar_Recentlycompared
        cache_lifetime = 86400
      • welcome_message = {Mage_Core_Model_Config_Element}[4]
        block = page/html_welcome
        placeholder = WELCOME
        container = Enterprise_PageCache_Model_Container_Welcome
        cache_lifetime = 86400
      • account_links = {Mage_Core_Model_Config_Element}[5]
        block = page/template_links
        name = account.links
        placeholder = ACCLINKS
        container = Enterprise_PageCache_Model_Container_Accountlinks
        cache_lifetime = 86400
      • wishlist = {Mage_Core_Model_Config_Element}[4]
        block = enterprise_wishlist/customer_sidebar
        placeholder = WISHLIST
        container = Enterprise_PageCache_Model_Container_Wishlist
        cache_lifetime = 86400
      • orders = {Mage_Core_Model_Config_Element}[4]
        block = sales/reorder_sidebar
        placeholder = ORDERS
        container = Enterprise_PageCache_Model_Container_Orders
        cache_lifetime = 86400
      • wishlist_links = {Mage_Core_Model_Config_Element}[4]
        block = enterprise_wishlist/links
        placeholder = WISHLISTLINKS
        container = Enterprise_PageCache_Model_Container_Wishlistlinks
        cache_lifetime = 86400
      • poll_activepoll = {Mage_Core_Model_Config_Element}[4]
        block = poll/activePoll
        placeholder = POLL
        container = Enterprise_PageCache_Model_Container_Sidebar_Poll
        cache_lifetime = 86400
      • widget_enterprise_banner ={Mage_Core_Model_Config_Element}[4]
        block = enterprise_banner/widget_banner
        placeholder = WIDGET_ENTERPRISE_BANNER
        container = Enterprise_PageCache_Model_Container_Banner
        cache_lifetime = 86400
      • catalog_product_item_related ={Mage_Core_Model_Config_Element}[5]
        block = enterprise_targetrule/catalog_product_item
        name = catalog.product.related.item
        placeholder = CATALOG_PRODUCT_ITEM_RELATED
        container = Enterprise_PageCache_Model_Container_CatalogProductItem
        cache_lifetime = 86400
      • catalog_product_item_upsell ={Mage_Core_Model_Config_Element}[5]
        block = enterprise_targetrule/catalog_product_item
        name = catalog.product.upsell.item
        placeholder = CATALOG_PRODUCT_ITEM_UPSELL
        container = Enterprise_PageCache_Model_Container_CatalogProductItem
        cache_lifetime = 86400
      • giftcard_form = {Mage_Core_Model_Config_Element}[5]
        block = enterprise_giftcard/catalog_product_view_type_giftcard_form
        name = product.info.giftcard.form
        placeholder = GIFTCARD
        container = Enterprise_PageCache_Model_Container_Giftcard
        cache_lifetime = 86400
      • catalog_product_list_related = {Mage_Core_Model_Config_Element}[5]
        block = catalog/product_list_related
        name = catalog.product.related
        placeholder = CATALOG_PRODUCT_LIST_RELATED
        container = Enterprise_PageCache_Model_Container_CatalogProductList
        cache_lifetime = 86400
      • catalog_product_list_upsell = {Mage_Core_Model_Config_Element}[5]
        block = catalog/product_list_upsell
        name = product.info.upsell
        placeholder = CATALOG_PRODUCT_LIST_UPSELL
        container = Enterprise_PageCache_Model_Container_CatalogProductList
        cache_lifetime = 86400
      • wishlist_list = {Mage_Core_Model_Config_Element}[4]
        block = enterprise_wishlist/behaviour
        placeholder = WISHLISTS
        container = Enterprise_PageCache_Model_Container_Wishlists
        cache_lifetime = 86400
      • $_cacheId = cache_config
        $_cacheTags = {array}[0]
        $_cacheLifetime = null
        $_cacheChecksum = null
        $_cacheSaved = true
        $_cache = {Varian_Cache_Core}[7]
        $_directivesList = {array}[3]
        [0] = lifetime
        [1] = logging
        [2] = logger

        $_specificOptions = {array}[1]
        slab_size = 1040000

        $_backend = {Zend_Cache_Backend_File}[3]
        option = {array}[9]
        cache_dir = E:\xampp\htdocs\oscp-store\
        magento_enterprise\var\cache\
        file_locking = true
        read_control = true
        read_control_type = crc32
        hashed_directory_level = 1
        hashed_directory_umask = 511
        file_name_prefix = mage
        cache_file_umask = 384
        metadatas_array_max_size = 100
        metadatasArray = {array}[42]
        1]181_CORE_CACHE_OPTIONS = {array}[4]
        hash = -1622867522
        mtime = 1404192731
        expire = 9999999999
        tags = {array}[1]
        [0]=181_MAGE

        $_directives = {array}[3]
        lifetime = 7200
        logging = false
        logger = null
        $_option ={array}[9]
        write_control = true
        caching = true
        cache_id_prefix = “181_”
        automatic_serialization = false
        automatic_cleaning_factor = 0
        lifetime = 7200
        logging = false
        logger = null
        ignore_user_abort = false

        *Zend_Cache_Core*_lastId = 181_5CD2F15D495B6256DBB59E18DE5B17C2

        $_extendedBackend = true

        $_backendCapabilities = {array}[6]
        automatic_cleaning = true
        tags = true
        expired_read = true
        priority = false
        infinite_lifetime = true
        get_list = true

        $_elementClass = Varien_Simplexml_Element

        $_xpathExtends = //*[@extends]

  • $_isEnabled = true

Variables: These values for product listing page
URL:
http://localhost/oscp-store/magento_enterprise/furniture/living-room

Only variation in:

  •  $_processor ={Enterprise_PageCache_Model_Processor}[7]
    $_requestId=>localhost/oscp-store/magento_enterprise/furniture/living-room
      $_requestCacheId => REQEST_c0681f91932d2db8d8e43c10c5ec3002
      $_requestTags =>Array [6]
                   	 [0] = FPC
    	         [1] = catalog_category
    	         [2] = catalog_category_10
    		 [3] = catalog_category_22
    	         [4] = catalog_category_13
    	         [5] = catalog_category_8
    
     $_metaData => null
     $_designExceptionExistsInCache => false
     $_requestProcessor => false
     $_subprocessor => null 
  • $_config = same as homepage
  • $_isEnabled = same as homepage

Variables: These values for Product Info Page
URL:
http://localhost/oscp-store/magento_enterprise/furniture/living-room/couch.html

Only variation in:

  •  $_processor ={Enterprise_PageCache_Model_Processor}[7]
    $_requestId=>localhost/oscp-store/ 
              magento_enterprise/furniture/living-room/couch.html
    $_requestCacheId => REQEST_eb1831bcdf8fc9de0165868aad7a61d2
    $_requestTags =>Array [1]
                   [0] = FPC
    $_metaData => null
    $_designExceptionExistsInCache => false
    $_requestProcessor => false
    $_subprocessor => null 
  • $_config = same as homepage
  • $_isEnabled = same as homepage