Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
5.1k views
in Technique[技术] by (71.8m points)

performance - Discussion about block html cache in Magento 1 CE

For my own shame I always was misunderstanding of how cache works.

This cache is being checked during rendering of each block as Mage_Core_Block_Abstract@toHtml with _loadCache() method. If this method return html - we're beautiful - dont need to render anything. Otherwise - process templates. Sounds fine until we're getting inside of _loadCache(). It literally says:

if (is_null($this->getCacheLifetime()) || !$this->_getApp()->useCache(self::CACHE_GROUP)) {
    return false;
}

Second part is checking if cache is enabled in admin. Thats fine. First one is more interesting - it checks lifetime that was set for particular block. I decided to check lifetime of each block on product page of clean Magento with official sample data and noticed that only 2 of 80 blocks have set their lifetime. Which basically means that rest 78 are not being cached.

My question - why? I always was pretty sure that most of block are being cached, thats makes sence. And now I found it's not. Please, tell me if I'm wrong at any of this points or if I'm not - why is this happened?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...