Skip to content

Instantly share code, notes, and snippets.

@Marko-M
Last active March 25, 2016 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marko-M/c937ff0084ca7e7b7109 to your computer and use it in GitHub Desktop.
Save Marko-M/c937ff0084ca7e7b7109 to your computer and use it in GitHub Desktop.
Magento improvement targeting FPC/block_html compatibility causing one cache storage access per layout block issue
--- app/code/core/Mage/Core/Block/Abstract.php 2016-03-25 14:22:51.934883000 +0100
+++ app/code/local/Mage/Core/Block/Abstract.php 2016-03-25 14:39:53.806883000 +0100
@@ -1,4 +1,17 @@
<?php
+/*
+ * Prevent unnecessary requests to cache storage on
+ *
+ * core_block_abstract_to_html_after
+ *
+ * due to
+ *
+ * enterprise_pagecache/observer::registerBlockTags
+ *
+ * calling $block->getCacheTags() on every block, with each block adding another cache storage request to fetch
+ * block tags for adding to cache tags for current FPC request in case particular block was pulled from block_html cache.
+ */
+
/**
* Magento Enterprise Edition
*
@@ -1306,14 +1319,22 @@
/**
* Get tags array for saving cache
*
+ * Inchoo: Lookup cache tags in cache storage only if block is block_html cacheable because
+ * only these blocks will have cache tags saved to cache storage to begin with (consult self::_saveCache).
+ *
* @return array
*/
public function getCacheTags()
{
- $tagsCache = $this->_getApp()->loadCache($this->_getTagsCacheKey());
- if ($tagsCache) {
- $tags = json_decode($tagsCache);
+ // Inchoo: START
+ if (!is_null($this->getCacheLifetime()) && $this->_getApp()->useCache(self::CACHE_GROUP)) {
+ $tagsCache = $this->_getApp()->loadCache($this->_getTagsCacheKey());
+ if ($tagsCache) {
+ $tags = json_decode($tagsCache);
+ }
}
+ // Inchoo: END
+
if (!isset($tags) || !is_array($tags) || empty($tags)) {
$tags = !$this->hasData(self::CACHE_TAGS_DATA_KEY) ? array() : $this->getData(self::CACHE_TAGS_DATA_KEY);
if (!in_array(self::CACHE_GROUP, $tags)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment